A simple Mail problem in search for a equally simple answer 
Author Message
 A simple Mail problem in search for a equally simple answer

Yo all

  I have a simple question about mailing in Visual Basic :

How can I create and send an email with a couple of files attached without
input from the user. The code I was writing is the following (doesn't seem
to work) :

Mail_Msg.Compose

Mail_Msg.MsgSubject = "NewMsg"
Mail_Msg.MsgNoteText = "Hallo"
Mail_Msg.AttachmentPathName = "d:\werf.pkt"
Mail_Msg.Send

I always get the error : 32002 Unspecified failure has occured

If you know how to send a file like this please send some code to

attachements.

   Cya
    Greetz from David



Sat, 05 Aug 2000 03:00:00 GMT  
 A simple Mail problem in search for a equally simple answer

Hi, this code works as I've just tested it.

Slap a MAPI session and the MAPI messages on a form with a command
button
Replace the wacky names with real ones.  
It will resolve for aliases aswell

Good Luck

Dave Titley
Business Analyst
UK

Private Sub Command1_Click()
               Const SESSION_SIGNON = 1
               Const MESSAGE_COMPOSE = 6
               Const ATTACHTYPE_DATA = 0
               Const RECIPTYPE_TO = 1
               Const RECIPTYPE_CC = 2
               Const MESSAGE_RESOLVENAME = 13
               Const MESSAGE_SEND = 3
               Const SESSION_SIGNOFF = 2

               MAPISession1.Action = SESSION_SIGNON
               MAPIMessages1.SessionID = Form1.MAPISession1.SessionID
               MAPIMessages1.Action = MESSAGE_COMPOSE  
               MAPIMessages1.MsgSubject = "This is the subject."
               MAPIMessages1.MsgNoteText = "This is the mail message."

               'The following four lines of code add an attachment to
the message,
               'and set the character position within the MsgNoteText
where the
               'attachment icon will appear. A value of 0 means the
attachment will
               'replace the first character in the MsgNoteText. You must
have at
               'least one character in the MsgNoteText to be able to
attach a file.
               MAPIMessages1.AttachmentPosition = 0
               'Set the type of attachment:
               MAPIMessages1.AttachmentType = ATTACHTYPE_DATA
               'Set the icon title of attachment:
               MAPIMessages1.AttachmentName = "System Configuration
File"
               'Set the path and file name of the attachment:
               MAPIMessages1.AttachmentPathName = "C:\CONFIG.SYS"

               'Set the recipients
               MAPIMessages1.RecipIndex =
0                                   'First recipient
               MAPIMessages1.RecipType =
RECIPTYPE_TO                         'Recipient in TO line
               MAPIMessages1.RecipDisplayName =

               MAPIMessages1.RecipIndex =
1                                   'add a second recipient
               MAPIMessages1.RecipType =
RECIPTYPE_TO                         'Recipient in TO line
               MAPIMessages1.RecipDisplayName =
"TanyaLasagna"                'e-mail name
               MAPIMessages1.RecipIndex =
2                                   'Add a third recipient
               MAPIMessages1.RecipType =
RECIPTYPE_CC                         'Recipient in CC line
               MAPIMessages1.RecipDisplayName =
"BlairAngelHair"              'e-mail name
               MAPIMessages1.RecipIndex =
3                                   'Add a fourth recipient
               MAPIMessages1.RecipType =
RECIPTYPE_CC                         'Recipient on CC Line
               MAPIMessages1.RecipDisplayName =
"JoanieCannelloni"            'e-mail name"

               'MESSAGE_RESOLVENAME checks to ensure the recipient is
valid and puts
               'the recipient address in MapiMessages1.RecipAddress
               'If the E-Mail name is not valid, a trappable error will
occur.
               MAPIMessages1.Action = MESSAGE_RESOLVENAME
               'Send the message:
               MAPIMessages1.Action = MESSAGE_SEND

               'Close MAPI mail session:
               MAPISession1.Action = SESSION_SIGNOFF
        End Sub
-----------------------------------------------

Quote:

> Yo all

>   I have a simple question about mailing in visual basic :

> How can I create and send an email with a couple of files attached without
> input from the user. The code I was writing is the following (doesn't seem
> to work) :

> Mail_Msg.Compose

> Mail_Msg.MsgSubject = "NewMsg"
> Mail_Msg.MsgNoteText = "Hallo"
> Mail_Msg.AttachmentPathName = "d:\werf.pkt"
> Mail_Msg.Send

> I always get the error : 32002 Unspecified failure has occured

> If you know how to send a file like this please send some code to

> attachements.

>    Cya
>     Greetz from David



Sat, 05 Aug 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. SIMPLE QUESTION : SIMPLE ANSWER?

2. SIMPLE QUESTION : SIMPLE ANSWER?

3. SIMPLE QUESTION, please SIMPLE ANSWER

4. Simple Question...simple answer???

5. HELP! simple question need simple answer

6. HELP! simple question need simple answer

7. HELP! simple question need simple answer

8. Mail Problem searching answers

9. Simple mail problem

10. Send Simple E-Mail Message without E-Mail client

11. Anyone want answer a simple question???

12. ADO Report - Simple Answer (Probably)

 

 
Powered by phpBB® Forum Software