How to: Specify an Internet Encoding Scheme for the Body and Attachments of a Message
Collapse the table of content
Expand the table of content
The document is archived and information here might be outdated

How to: Specify an Internet Encoding Scheme for the Body and Attachments of a Message

Office 2007

This topic shows how to use the MAPI property, PR_INETMAIL_OVERRIDE_FORMAT, and the Outlook object model to specify an Internet encoding scheme for the Exchange Internet Mail Service (IMS) to encode the body and attachments of a mail item.

The following code sample in Visual C# shows how to reference PR_INETMAIL_OVERRIDE_FORMAT with its MAPI proptag namespace and use the PropertyAccessor object of the Outlook object model to specify MIME as the Internet encoding scheme for a message. PR_INETMAIL_OVERRIDE_FORMAT is referenced as:
where 0x59020003 is the proptag of PR_INETMAIL_OVERRIDE_FORMAT.
private void SendMail_Click()
    Outlook.NameSpace objSession;
    Outlook.MailItem objMailItem;
    Outlook.Recipient objRecipient;
    Outlook.PropertyAccessor oPA;

    string Recipient, MsgSubject, ImageFile, TextFile, FileLocation, PropName;
    int EncodingFlag;

    //Modify the following to appropriate values.
    Recipient = "";
    EncodingFlag = 1; //Use MIME encoding
    MsgSubject = "Test Encoding";
    ImageFile = "garden.jpg";
    TextFile = "mytext.txt";
    FileLocation = "c:\\";

    objSession = Application.GetNamespace("MAPI");
    objSession.Logon(null, null, true, null);

    objMailItem = Application.CreateItem(
                Outlook.OlItemType.olMailItem) as Outlook.MailItem;
    objMailItem.Subject = MsgSubject;
    objMailItem.Body = "body";
    objMailItem.Attachments.Add(FileLocation + TextFile, 
        Outlook.OlAttachmentType.olByValue, 1, TextFile);
    objMailItem.Attachments.Add(FileLocation + ImageFile,
        Outlook.OlAttachmentType.olByValue, 1, ImageFile);

    objRecipient = objMailItem.Recipients.Add(Recipient);

    PropName = "";
    oPA = objMailItem.PropertyAccessor;
    oPA.SetProperty(PropName, EncodingFlag);




© 2016 Microsoft