ComposeBody
MSMQMailEMail

The ComposeBody method creates the body of an MSMQ mail message based on an e-mail message.

Syntax

varBody=object.ComposeBody
 
Syntax Element Description
object E-mail message (MSMQMailEMail) object that defines the e-mail message.
varBody Variant type (array of bytes) body of an MSMQ mail message.

Return Values

Byte-array message body.

Remarks

The returned byte-array can be used as the body of an MSMQ mail message.

The following table defines the properties of the MSMQMailEMail object that are required to compose a message body for each type of e-mail. Required properties are marked with an X (default values can be used). When composing an e-mail object, all required properties must have valid values, otherwise an error condition is raised by ComposeBody.



MSMQMailEMail

Text
Message


Form


TNEF

Delivery
Report
Non-
Delivery
Report
ContentType X X X X X
DeliveryReportData X
DestinationQueueLabels
FormData X
NonDeliveryReportData X
Recipients X X X X X
RequestDeliveryReport X (False) X (False)
RequestNonDeliveryReport X (False) X (False)
Sender X X
Subject X (Empty string) X (Empty string)
SubmissionTime X (Creation time of
e-mail object)
X (Creation time of
e-mail object)
X (Creation time of
e-mail object)
X (Creation time of
e-mail object)
TestMessageData X
TnefData X

Example

This example defines an e-mail message, composes the body of an MSMQ message (formatted in MSMQ mail format), and prints out the body of the message.

To try this example using Microsoft Visual Basic (version 5.0), paste the code into the Code window of a form, run the example, and click the form.

Dim email As New MSMQMailEMail
Dim msg As New MSMQMessage

Private Sub Form_Click()
   
   '*********************
   '*  Define the e-mail
   '*********************
   
   'Set e-mail type as text message
   email.ContentType = MSMQMAIL_EMAIL_TEXTMESSAGE
   
   'Set who receives the e-mail.
   email.Recipients.Add "RecipientName", "RecipientQueueLabel", MSMQMAIL_RECIPIENT_TO
   
   'Set who sent the e-mail.
   email.Sender.Name = "Our name"
   email.Sender.Address = "Our queue label"
   
   'Set the subject of the e-mail.
   email.Subject = "Test mail."
   
   'Set the Body of the e-mail.
   email.TextMessageData.Text = "This is the Body of the e-mail message."
   
   'Compose the MSMQ mail message Body.
   msg.Body = email.ComposeBody
   
   
   '*********************************
   '*  Display the MSMQ message Body.
   '*********************************
   
   'Display the mail message Body.
   Dim lTmp As Long
   For lTmp = LBound(msg.Body) To UBound(msg.Body)
       Debug.Print Chr$(msg.Body(lTmp));
   Next lTmp


End Sub
 

QuickInfo

  Windows NT: Requires version 4.0 SP3 or later.
  Windows: Requires Windows 95 or later.
  Windows CE: Unsupported.
  Import Library: Included as a resource in mqmailoa.dll.
  Unicode: Defined only as Unicode.

See Also

Add, Address, Body, ContentType, MSMQMailEMail, MSMQMessage, Name, Recipients, Sender, Subject, Text, TextMessageData