HOWTO: Attatch .ics, .mht files with CDOSYS/System.Web.Mail



Note:  By setting the ContentMediaType property of the attatchment body part object to "text/html", you should be able to
           properly attatch most any type of file.   This includes .mht, .ics, etc.


Example:


     // Attatch needed files.    // TODO: Change this section or comment-out
    String sFile = @"C:\dev\mapi\test.mht";  // File to attatch  
    oBP = oMsg.AddAttachment(sFile,"","");  // Do Attatchment
    oBP.ContentMediaType = "text/html";   // Set ContentMediaType - mht files need this setting.


You may find that attachments need to be UU Encoded uner .NET.  Below is an example of VB.NET code (System.Web.Mail).


Dim oAttch As MailAttachment
oAttch = New MailAttachment(SendFilesPath, MailEncoding.UUEncode)
oMail.Attachments.Add(oAttch)



 

Comments (0)

Skip to main content