aspNetEmail

EmbeddedObject.ContentLocation Property

Can be used in place of ContentID, and is much more friendly when getting the body content of an email from an html file.

public string ContentLocation {get; set;}

Remarks

According to RFC2557 -- A Content-Location header specifies an URI that labels the content of a body part in whose heading it is placed. Its value CAN be an absolute or a relative URI. Any URI or URL scheme may be used, but use of non-standardized URI or URL schemes might entail some risk that recipients cannot handle them correctly. An URI in a Content-Location header need not refer to an resource which is globally available for retrieval using this URI (after resolution of relative URIs). However, URI-s in Content-Location headers (if absolute, or resolvable to absolute URIs) SHOULD still be globally unique.

Example

             EmailMessage msg = new EmailMessage( "mail.mycompany.com");
             msg.FromAddress = "me@mycompany.com";
             msg.To = "you@yourcompany.com";
             msg.Subject="Company Logo";
             
             //add the html bodypart
             msg.HtmlBodyPart = "<b>What do you think of the cool new logo?</b><img src=http://whatever/images/CompanyLogo.gif>";
             
             //embed and add the embedded object
             EmbeddedObject o = new EmbeddedObject();
             o.Name	= "logo.gif";
             o.ContentType= "image/gif";
             o.ContentLocation = "http://whatever/images/CompanyLogo.gif";
             o.FilePath = "logo.gif";
             msg.EmbedObject( o );
             
             msg.Send();
             
             
             Dim msg As EmailMessage = New EmailMessage("mail.mycompany.com")
             msg.FromAddress = "me@mycompany.com"
             msg.To = "you@yourcompany.com"
             msg.Subject = "Company Logo"
             
             'add the html bodypart
             msg.HtmlBodyPart = "<b>What do you think of the cool new logo?</b><img src=http://whatever/images/CompanyLogo.gif>"
             
             'embed and add the embedded object
             Dim o As EmbeddedObject = New EmbeddedObject()
             o.Name = "logo.gif"
             o.ContentType = "image/gif"
             o.ContentLocation = "http://whatever/images/CompanyLogo.gif"
             o.FilePath = "logo.gif"
             msg.EmbedObject(o)
             
             msg.Send()
             

See Also

EmbeddedObject Class | aspNetEmail Namespace