Microsoft KB Archive/278321

= How To Force a Particular Internet Encoding by Using MAPI =

Article ID: 278321

Article Last Modified on 2/22/2007

-

APPLIES TO


 * Microsoft Exchange Server 5.5 Standard Edition
 * Microsoft Exchange 2000 Server Standard Edition

-



This article was previously published under Q278321



SUMMARY
You can use the Messaging Application Programming Interface (MAPI) property PR_INETMAIL_OVERRIDE_FORMAT (0x59020003) to force the Exchange Internet Mail Service (IMS) to use a particular encoding scheme for the message body and attachments. This per-message property can be set in both Collaboration Data Objects (CDO) and Extended MAPI code.



MORE INFORMATION
The possible values of PR_INETMAIL_OVERRIDE_FORMAT, which correspond to the Send Options settings in Microsoft Outlook, are as follows:

Sample Code for CDO
The following CDO Microsoft Visual Basic code sends a MIME message with two attachments, encoded with Base64: ' Reference to Microsoft CDO 1.21 library. Private Sub SendMail_Click Dim objSession As MAPI.Session Dim objMessage As MAPI.Message Dim objAttachments As MAPI.Attachments Dim objAttachment As MAPI.Attachment Dim objRecipients As MAPI.Recipients Dim objRecipient As MAPI.Recipient Dim Recipient As String Dim MsgSubject As String Dim EncodingFlag As Integer Dim bmpFile As String Dim txtFile As String Dim FileLocation As String 'TODO: Modify the following to appropriate values. Recipient = &quot;myaccount@hotmail.com&quot; EncodingFlag = 1 'Use MIME encoding bmpFile = &quot;mybmp.bmp&quot; txtFile = &quot;mytxt.txt&quot; FileLocation = &quot;c:\&quot; MsgSubject = &quot;Test Encoding: &quot; & EncodingFlag On Error GoTo Err Set objSession = CreateObject(&quot;MAPI.Session&quot;) objSession.Logon showdialog:=True Set objMessage = objSession.Outbox.Messages.Add(MsgSubject, &quot;body&quot;) Set objAttachments = objMessage.Attachments objAttachments.Add txtFile, 0, CdoFileData, FileLocation & txtFile objAttachments.Add bmpFile, 0, CdoFileData, FileLocation & bmpFile Set objRecipients = objMessage.Recipients Set objRecipient = objRecipients.Add objRecipient.Name = Recipient objRecipient.Resolve objMessage.Fields.Add &H59020003, EncodingFlag objMessage.Update objMessage.Send True Err: If Err.Number Then Debug.Print Err.Number & &quot;: &quot; & Err.Description & &quot;::&quot; & Err.Source Err.Clear End If   If Not objSession Is Nothing Then objSession.Logoff

End Sub An issue in the CDO ReadFromFile method can interfere with the encoding process. If ReadFromFile is used, CdoPR_ATTACH_LONG_FILENAME needs to be set on the attachment. For more information, see the following article in the Microsoft Knowledge Base:

278358 PRB: File Attached Via CDO Has Incorrect Filename

Headers for MAPI
You can use this property from Extended MAPI code as well; the following #defines will help:
 * 1) define PR_INETMAIL_OVERRIDE_FORMAT PROP_TAG(PT_LONG,0x5902)


 * 1) define ENCODEDONTKNOW 0
 * 2) define ENCODEMIME 1
 * 3) define ENCODEUUENCODE 2
 * 4) define ENCODEBINHEX 3

Important Notes
The encoding specified in PR_INETMAIL_OVERRIDE_FORMAT take effect only if the IMS does not encode the message as Rich Text/TNEF. For information on preventing the use of transport-neutral encapsulation format (TNEF), see the following article:

149203 XFOR: Preventing Winmail.dat From Being Sent Over IMC

The information in this article applies only to mail that is sent through the Exchange Internet Mail Connector (IMC). It does not apply to mail that is sent through the Outlook Internet Mail Provider.

