Platform SDK: Exchange 2000 Server |
[This is preliminary documentation and subject to change.]
The IMessage.AddAttachment method adds an attachment to a message. The AddAttachment method accepts a file, ftp, http, or https URL parameter that identifies the attachment's location. The method returns a reference to the newly added BodyPart object that houses the attachment so that it can be further manipulated if needed.
The following example shows how to add a GIF graphic and a Microsoft® Word file as attachments to a message.
' Reference to Microsoft ActiveX Data Objects 2.5 Library ' Reference to Microsoft CDO for Exchange 2000 Server Library ' .. Dim iMsg as New CDO.Message ' configure message here if necessary With iMsg .To = "someone@microsoft.com" .From = "another@microsoft.com" .Newsgroups = "comp.microsoft.newsgroup1" .Subject = "Agenda for staff meeting" .TextBody = "See attached docs for more info." .AddAttachment "http://example.microsoft.com/picture.gif" .AddAttachment "file://d:/temp/test.doc" .AddAttachment "C:\files\another.doc" ' finish and send End With
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace #import "c:\exchsrvr\cdoex.dll" no_namespace // ... IMessagePtr iMsg(__uuidof(Message)); /* ** configure message here if necessary */ iMsg->To = "someone@microsoft.com"; iMsg->From = "another@microsoft.com"; iMsg->Newsgroups = "comp.microsoft.newsgroup1"; iMsg->Subject = "Agenda for staff meeting"; iMsg->TextBody = "See attached docs for more info."; try { iMsg->AddAttachment("http://example.microsoft.com/picture.gif","",""); iMsg->AddAttachment("file://d:/temp/test.doc","",""); iMsg->AddAttachment("C:\files\another.doc","",""); } catch(_com_error err) { // handle exception } // finish and send
Dim iMsg Set iMsg = CreateObject("CDO.Message") ' configure message here if necessary With iMsg .To = "someone@microsoft.com" .From = "another@microsoft.com" .Newsgroups = "comp.microsoft.newsgroup1" .Subject = "Agenda for staff meeting" .TextBody = "See attached docs for more info." .AddAttachment "http://example.microsoft.com/picture.gif" .AddAttachment "file://d:/temp/test.doc" .AddAttachment "C:\files\another.doc" ' .. End With
Note If you attach a Web page using the AddAttachment method, you attach only the file specified in the URL. If the page contains image links or other content, they are not included. To attach a full Web page with embedded graphics, use the IMessage.CreateMHTMLBody method. For more information on attaching Web pages, see Creating MHTML Messages.