共用方式為


指定訊息本文和附件的網際網路編碼配置

本主題說明如何使用 MAPI 屬性 PidTagInternetMailOverrideFormat和 Microsoft Outlook 物件模型來指定 Exchange Internet Mail Service (IMS) 的網際網路編碼配置,以編碼訊息項目的本文和附件。

Visual C# 中的下列程式碼範例示範如何參考 PidTagInternetMailOverrideFormat 及其 MAPI proptag 命名空間,並使用 Outlook 物件模型的 PropertyAccessor 物件,將 MIME 指定為訊息的網際網路編碼配置。 PidTagInternetMailOverrideFormat 參考為:

https://schemas.microsoft.com/mapi/proptag/0x59020003

其中 0x59020003PidTagInternetMailOverrideFormat 的 proptag

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 = "someone@example.com"; 
    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); 
    objRecipient.Resolve(); 
 
    PropName = "https://schemas.microsoft.com/mapi/proptag/0x59020003"; 
    oPA = objMailItem.PropertyAccessor; 
    oPA.SetProperty(PropName, EncodingFlag); 
 
    objMailItem.Send(); 
 
    objSession.Logoff(); 
 
}

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應