Platform SDK: Exchange 2000 Server

Addressing the Message

[This is preliminary documentation and subject to change.]

To send a message, you must specify at least one recipient’s address by using the IMessage.To, IMessage.CC, or IMessage.BCC property. To post an NNTP message, you must specify at least one newsgroup’s address by using the IMessage.Newsgroups property.

Address Formats

The address formats are defined by various Internet standards:

SMTP Addresses
recipient@microsoft.com
<recipient@microsoft.com>
"Display Name" <recipient@microsoft.com>
NNTP Newsgroup Names
comp.os.windows
comp.microsoft.newsgroup1

Note   Multiple addressees for a message are separated with commas only. The semi-colons used with MAPI clients such as Microsoft Outlook® are not used.

"Mr. A" <a@microsoft.com>, "Mr. B" <b@microsoft.com>
A@microsoft.com, <B@microsoft.com>, "Mr. C" <c@microsoft.com>
comp.microsoft.newsgroup1, comp.microsoft.newsgroups2

All addresses must be complete addresses or newsgroup names. The following examples show how to address a message by using the IMessage.To or IMessage.Newsgroup property.

[Visual Basic]
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Exchange 2000 Server Library
' ..
Dim iMsg as New CDO.Message

iMsg.To         = "someone@microsoft.com"
iMsg.Newsgroups = "comp.microsoft.newsgroup"
[C++,IDL]
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace
#import "c:\exchsrvr\cdoex.dll" no_namespace
// ...
IMessagePtr iMsg(__uuidof(Message));

iMsg->To         = "someone@microsoft.com";
iMsg->Newsgroups = "comp.microsoft.newsgroup";
[VBScript]
Dim iMsg
Set iMsg = CreateObject("CDO.Message")

iMsg.To         = "someone@microsoft.com"
iMsg.Newsgroups = "comp.microsoft.newsgroup"

Note   Trailing commas are removed from address strings by the address field parser each time you set an address property. To concatenate address fields, place the comma at the beginning of the string being added. You can also concatenate the addresses prior to setting the value of the address field. This note applies to the To, CC, BCC, FollowUpTo, and Newsgroup properties. For example:

iMsg.To = "someone@microsoft.com"
iMsg.To = iMsg.To & ",another@microsoft.com"

The IMessage interface exposes properties that relate to the most common mail header fields such as To, From, CC, BCC, Newsgroups and FollowUpTo. However, the complete list of headers for the message is contained in the IMessage.Fields collection. Fields used with a Message object reside in the urn:schemas:mailheader: and urn:schemas:httpmail: namespaces. Consequently, you can use the Fields collection to set mail header fields used to address the message if desired.

[Visual Basic]
' Reference to Microsoft ActiveX Data Objects 2.5 Library
' Reference to Microsoft CDO for Exchange 2000 Server Library
' ..
Dim iMsg as New CDO.Message

Dim Flds as ADODB.Fields
Set Flds = iMsg.Fields
With Flds
  .Item("urn:schemas:mailheader:to")   = "someone@microsoft.com"
  .Item("urn:schemas:mailheader:from") = "<another@microsoft.com>"
  .Item("urn:schemas:mailheader:cc")   = "<thirdperson@microsoft.com>"
  .Update
End With
  ' ..
[C++,IDL]
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace
#import "c:\exchsrvr\cdoex.dll" no_namespace
// ...
IMessagePtr iMsg(__uuidof(Message));

FieldsPtr Flds;
Flds = iMsg->Fields;
Flds->Item["urn:schemas:mailheader:to"]->Value = _variant_t("someone@microsoft.com");
Flds->Item["urn:schemas:mailheader:from"]->Value = _variant_t("<another@microsoft.com>");
Flds->Item["urn:schemas:mailheader:cc"]->Value = _variant_t("<thirdperson@microsoft.com>");
Flds->Update();
[VBScript]
Dim iMsg
Set iMsg = CreateObject("CDO.Message")

Dim Flds
Set Flds = iMsg.Fields
With Flds
  .Item("urn:schemas:mailheader:to")   = "someone@microsoft.com"
  .Item("urn:schemas:mailheader:from") = "<another@microsoft.com>"
  .Item("urn:schemas:mailheader:cc")   = "<thirdperson@microsoft.com>"
  .Update
End With

See Also

IMessage.To

IMessage.CC

IMessage.BCC

IMessage.From

urn:schemas:mailheader: Namespace