Platform SDK: CDO for Windows 2000 |
When sending a message, setting the subject field is optional, but is normally specified. When posting a message to a newsgroup, setting the subject field is required. For both message types, setting the text body field is optional, but is also normally specified.
You can set the subject and text body fields using the IMessage.Subject and IMessage.TextBody properties.
' Reference to Microsoft ActiveX Data Objects 2.5 Library ' Reference to Microsoft CDO for Windows 2000 Library Dim iMsg as New CDO.Message With iMsg .To = "someone@microsoft.com" .Newsgroups = "comp.microsoft.newsgroup1" .Subject = "Agenda for staff meeting" .TextBody = "Please plan to present your status for the following projects..." End With
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace #import <cdosys.dll> no_namespace // ... IMessagePtr iMsg(__uuidof(Message)); iMsg->To = "someone@microsoft.com"; iMsg->Newsgroups = "comp.microsoft.newsgroup1"; iMsg->Subject = "Agenda for staff meeting"; iMsg->TextBody = "Please plan to present your status for the following projects...";
Dim iMsg Set iMsg = CreateObject("CDO.Message") With iMsg .To = "someone@microsoft.com" .Newsgroups = "comp.microsoft.newsgroup1" .Subject = "Agenda for staff meeting" .TextBody = "Please plan to present your status for the following projects..." End With
You can use the IMessage.Fields collection to set the subject and text body of the message. The field names are urn:schemas:mailheader:subject, urn:schemas:httpmail:subject, and urn:schemas:httpmail:textdescription, respectively. The subject field within the urn:schemas:mailheader: field returns the subject with any non US-ASCII characters encoded according to Request For Comments (RFC) 1522. The subject field within the urn:schemas:httpmail: namespace contains the subject in Unicode characters.
' Reference to Microsoft ActiveX Data Objects 2.5 Library ' Reference to Microsoft CDO for Windows 2000 Library Dim iMsg as New CDO.Message Dim Flds as ADODB.Fields Set Flds = iMsg.Fields With Flds .Item("urn:schemas:httpmail:to") = "someone@microsoft.com" .Item("urn:schemas:httpmail:from") = "<another@microsoft.com>" .Item("urn:schemas:httpmail:cc") = "<thirdperson@microsoft.com>" .Item("urn:schemas:httpmail:subject") = "Agenda for the staff meeting" .Item("urn:schemas:httpmail:textdescription") = "Please plan to present your status for the following projects..." .Update End With
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace #import <cdosys.dll> no_namespace // ... IMessagePtr iMsg(__uuidof(Message)); FieldsPtr Flds; Flds = iMsg->Fields; Flds->Item["urn:schemas:mailheader:to"] = _variant_t("someone@microsoft.com"); Flds->Item["urn:schemas:mailheader:from"] = _variant_t("<another@microsoft.com>"); Flds->Item["urn:schemas:mailheader:cc"] = _variant_t("<thirdperson@microsoft.com>"); Flds->Item["urn:schemas:mailheader:subject"]->Value = _variant_t("Agenda for the staff meeting"); Flds->Item["urn:schemas:mailheader:textdescription"]->Value = _variant_t("Please plan to present your status for the following projects..."); Flds->Update();
Dim iMsg Set iMsg = CreateObject("CDO.Message") Dim Flds Set Flds = iMsg.Fields With Flds .Item("urn:schemas:httpmail:to") = "someone@microsoft.com" .Item("urn:schemas:httpmail:from") = "<another@microsoft.com>" .Item("urn:schemas:httpmail:cc") = "<thirdperson@microsoft.com>" .Item("urn:schemas:httpmail:subject") = "Agenda for the staff meeting" .Item("urn:schemas:httpmail:textdescription") = "Please plan to present your status for the following projects..." .Update End With
urn:schemas:httpmail:textdescription Field