Does anyone know how to attach file in outlook automation? 
Author Message
 Does anyone know how to attach file in outlook automation?

Does Anone know how to Attach file to Outlook Email Message?

I am using outlook automation to send email and I need to attach file to
message. Does any one know how to attach file?

Here is my code but attaching part is missing. Can anyone help?

 _Application da;
 if(!da.CreateDispatch("Outlook.Application.9"))
          AfxMessageBox("CreateDispatch failed.", MB_OK | MB_SETFOREGROUND);
 _MailItem myMail;
 myMail=da.CreateItem(0);

 myMail.SetBody("Message");

 /// Please tell me how to add attachment "D:\\File.txt"

 myMail.Save();



Wed, 08 Jun 2005 13:53:44 GMT  
 Does anyone know how to attach file in outlook automation?
Look in the MSDN under Microsoft Office (General)
I will Add an snippet from the document. The code is in VB but the idea is
clear. You have to get the da.Attachment. I don't have the outlook includes
but I expect something like.
I could sent you the document at your email address,  but you probably can
find it on the net.


_Application da;
_Attachment am;
if(!da.CreateDispatch("Outlook.Application.9"))
    AfxMessageBox("CreateDispatch failed.", MB_OK | MB_SETFOREGROUND);
_MailItem myMail;
myMail=da.CreateItem(0);
am = myMail.Attachment;

myMail.SetBody("Message");
am.Add("D:\\File.txt");

/// Please tell me how to add attachment "D:\\File.txt"

myMail.Save();

-- vbcode --

 Sub NewMailMessage()
    Dim ol As New Outlook.Application
    Dim ns As Outlook.NameSpace
    Dim newMail As Outlook.MailItem

    'Return a reference to the MAPI layer.
    Set ns = ol.GetNamespace("MAPI")

    'Create a new mail message item.
    Set newMail = ol.CreateItem(olMailItem)
    With newMail
        'Add the subject of the mail message.
        .Subject = "Training Information for October 1997"
        'Create some body text.
        .Body = "Here is the training information you requested:" & vbCrLf

        'Add a recipient and test to make sure that the
        'address is valid using the Resolve method.

            .Type = olTo
            If Not .Resolve Then
                MsgBox "Unable to resolve address.", vbInformation
                Exit Sub
            End If
        End With

        'Attach a file as a link with an icon.
        With .Attachments.Add _
            ("\\Training\training.xls", olByReference)
            .DisplayName = "Training info"
        End With

        'Send the mail message.
        .Send
    End With

    'Release memory.
    Set ol = Nothing
    Set ns = Nothing
    Set newMail = Nothing
End Sub



Quote:
> Does Anone know how to Attach file to Outlook Email Message?

> I am using outlook automation to send email and I need to attach file to
> message. Does any one know how to attach file?

> Here is my code but attaching part is missing. Can anyone help?

>  _Application da;
>  if(!da.CreateDispatch("Outlook.Application.9"))
>           AfxMessageBox("CreateDispatch failed.", MB_OK |
MB_SETFOREGROUND);
>  _MailItem myMail;
>  myMail=da.CreateItem(0);

>  myMail.SetBody("Message");

>  /// Please tell me how to add attachment "D:\\File.txt"

>  myMail.Save();



Thu, 16 Jun 2005 11:50:01 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Does anyone know how to attach file in outlook automation?

2. Does any one know how to attach file in outlook automation?

3. Does any one know how to attach file in outlook automation?

4. Does any one know how to attach file in outlook automation?

5. Does any one know how to attach file in outlook automation?

6. How to attach multiply files to outlook ?

7. Attaching file to outlook

8. Does anyone know how to play a .wav file in a c program

9. HELP, does anyone know the header info for a DLL file

10. .ICL Icon Format (Anyone knows the real File Format)

11. Anyone know how to programatically installing a display driver using an .INF file

12. Q: anyone know a wav file library?

 

 
Powered by phpBB® Forum Software