Platform SDK: Exchange 2000 Server |
[This is preliminary documentation and subject to change.]
The AddRelatedBodyPart method adds a BodyPart object that is referenced by content in the HTML body of the message.
[Visual Basic] Function AddRelatedBodyPart( ByVal URL as String, ByVal Reference as String, ByVal ReferenceType as CdoReferenceType, [ByVal UserName as String], [ByVal Password as String] ) as IBodyPart [C++] HRESULT AddRelatedBodyPart( BSTR URL, BSTR Reference, CdoReferenceType ReferenceType, [BSTR UserName,] [BSTR Password,] IBodyPart** pVal ); [IDL] HRESULT AddRelatedBodyPart( [in] BSTR URL, [in] BSTR Reference, [in] CdoReferenceType ReferenceType, [in, optional] BSTR UserName, [in, optional] BSTR Password, [out,retval] IBodyPart** pVal );
See Request for Comments (RFC) 2110 and RFC 2111 for further information on using Content-ID and Content-Location headers in messages formatted in MIME Encapsulation of Aggregate HTML Documents (MHTML).
This method is intended to associate a Uniform Resource Locator (URL) within the content of a Multipurpose Internet Mail Extensions (MIME) body part to another body part in the MIME hierarchy. The AddRelatedBodyPart method is commonly used to attach graphics inline instead of referring to them using a URL.
The AddRelatedBodyPart method creates a body part by getting the contents specified by the URL parameter. It returns the IBodyPart object reference on the BodyPart object that is added to the collection of body parts of this message.
Calling the AddRelatedBodyPart method causes this message to become an MHTML-formatted message. Microsoft Collaboration Data Objects (CDO) automatically sets the MimeFormatted property to True and constructs the necessary multipart/related body part hierarchy. The ContentMediaType property of the new HTML body part is automatically set to text/html. The Content-ID or Content-Location header field of the related body part is set using the mechanism specified using the Reference and ReferenceType parameters, and its Content-Disposition header field is set to inline.
Normally, you populate the IMessage.HTMLBody property before calling the AddRelatedBodyPart method. The HTML can contain links to graphics and other resources. If the HTMLBody property is not set, or if its tag does not match the Content-Location header field of the new body part, the AddRelatedBodyPart method adds the body part without relating it to anything else.
Use the UserName and Password parameters when you are requesting Web pages using the Hypertext Transfer Protocol (HTTP) from a server that requires client authentication. If the Web server supports only the basic or digest authentication mechanisms, these credentials must be supplied. By default the current process security context is used to authenticate when using the NTLM or Negotiate (Kerberos) security packages; however, you can specify alternate credentials with the UserName and Password parameters.
Dim iMsg as New CDO.Message ' ... .MimeFormatted defaults to True on the new message ... Dim strHTML as String ' string in which to build up HTML body ' ... Set iMsg = New CDO.Message strHTML = "<!DOCTYPE HTML PUBLIC ""-//IETF//DTD HTML//EN"">" & NL strHTML = strHTML & "<HTML>" strHTML = strHTML & " <HEAD>" strHTML = strHTML & " <TITLE>Sample GIF</TITLE>" strHTML = strHTML & " </HEAD>" strHTML = strHTML & " <BODY><P>" strHTML = strHTML & " <IMG src=""XYZ.gif""></p><p>Inline graphics</P>" strHTML = strHTML & " </BODY>" strHTML = strHTML & "</HTML>" iMsg.HTMLBody = strHTML iMsg.AddRelatedBodyPart "D:\wwwroot\XYZ.gif", "XYZ.gif", cdoRefTypeId iMsg.Send