DestinationQueueLabels
MSMQMailEMail

The DestinationQueueLabels property provides the label of each destination queue needed to send the MSMQ mail message. These labels are taken from the recipient addresses defined by the e-mail object.

Type: Collection of Strings
Run time: Read-only

Syntax

object.DestinationQueueLabels
 
Syntax Element Description
object An e-mail (MSMQMailEMail) object that defines an e-mail message.

Returned Value

String representation of each queue label needed to send message.

Remarks

Typically, a query is used to locate the destination queues of an e-mail. When running a query, make sure the queue type is added to the search criteria as well as the destination queue label. All application input queues, MAPI user input queues, and Exchange service input queues use the following MSMQ-defined queue type: MSMQMAIL_SERVICE_MAIL.

When sending mail to several Microsoft Exchange users via the MSMQ Exchange Connector, only one label is stored in the destination queue collection. Only one label is needed because the Exchange Connector has only one input queue.

Example

This example sends mail to each destination queue.

To try this example using Microsoft Visual Basic (version 5.0), paste the code into the Code window of a form, enter a valid user address for each recipient, run the example, and click the form.

Dim email As New MSMQMailEMail
Dim msg As New MSMQMessage


Private Sub Form_Click()

   '*********************
   '*  Define e-mail
   '*********************

   'Set e-mail type to text message.
   email.ContentType = MSMQMAIL_EMAIL_TEXTMESSAGE

   'Add recipient.
   email.Recipients.Add "User1", "User1Address", MSMQMAIL_RECIPIENT_TO
   email.Recipients.Add "User2", "User2Address", MSMQMAIL_RECIPIENT_CC
   
   'Set who sent the e-mail.
   email.Sender.Name = "Our name"
   email.Sender.Address = "Our queue label"

   'Set subject of mail.
   email.Subject = "Test form."
   
   'Set message text
   email.TextMessageData.Text = "This is a test message."


   '******************
   '* Compose message
   '******************
   msg.Body = email.ComposeBody
   
   '******************
   '* Send Message
   '******************
   
   Dim qLabel As Variant
      
   For Each qLabel In email.DestinationQueueLabels
       Dim query As MSMQQuery
       Dim qinfos As MSMQQueueInfos
       Dim qinfo As MSMQQueueInfo
       
       Set query = New MSMQQuery
       Set qinfos = query.LookupQueue(Label:=qLabel, ServiceTypeGuid:=MSMQMAIL_SERVICE_MAIL)
       
       qinfos.Reset
       Set qinfo = qinfos.Next
       
       If Not (qinfo Is Nothing) Then
          Dim qdestination As MSMQQueue
          Set qdestination = qinfo.Open(MQ_SEND_ACCESS, MQ_DENY_NONE)
          msg.Send qdestination
       End If
   
   Next qLabel

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, ComposeBody, ContentType, LookupQueue, MSMQMailEMail, MSMQMessage, MSMQQuery, MSMQQueue, MSMQQueueInfo, MSMQQueueInfos, Name, Open, Recipients, Send, Sender, Subject, Text, TextMessageData