HOWTO: Set SMTP Header Properties Using CDONTS

ID: Q233293


The information in this article applies to:


SUMMARY

Using Collaboration Data Objects for NTS (CDONTS), additional header information can be set for messages that are created using CDONTS. The Value property of the NewMail object allows additional header information to be added to the NewMail object in CDONTS. To add the new header to the CDONTS message, the string that the header is being set to must be assigned to the correct header name.

The correct syntax for this is as follows:


CDONTSNewMailObject.Value("Header String") = "Value that the header is being set to" 


MORE INFORMATION

The code below sets the Reply-To property on a message being sent using CDONTS.

  1. Cut and paste the following code into a Visual Basic Project.


  2. Add a reference to the CDONTS library to the project.




Private Sub Form_Load()
    Dim myCDONTSMail As CDONTS.NewMail
    Dim strFrom As String
    Dim strTo As String
    Dim strReply_To As String
    Dim strSubject As String
    Dim strMessage As String
    
     
     strFrom = "Sender@Company.com"
     strTo = "Recipient@Company.com"
     strReply_To = "Reply-To<Reply_To@Company.com>"
     strSubject = "This is the Subject"
     strBody = "This is the message body." 
     
     ' Create the CDONTS NewMail object    
     Set myCDONTSMail = CreateObject("CDONTS.NewMail")

     
     ' Set the Reply-To header of the Newmail object:
     myCDONTSMail.Value("Reply-To") = strReply_To
    
     ' Send the message and cleanup CDONTS objects    
     myCDONTSMail.Send strFrom, strTo, strSubject, strMessage
     Set myCDONTSMail = Nothing
End Sub
 
You can set the Value property more than once. Each setting generates another header to be included with the existing headers. For the headers to function correctly, the string that is added as a header exactly matches the accepted string.

A list of the accepted headers that can be used can be found in RFC 822.


REFERENCES

CDONTS object model on MSDN Library.
RFC 822

Additional query words: kbDSupport kbGrpMsg kbMsg kbCDO kbCDONTS kbVBp


Keywords          : kbCDO kbMsg kbVBp kbCDONTS kbGrpMsg kbDSupport 
Version           : WINDOWS:1.2
Platform          : WINDOWS 
Issue type        : kbhowto 

Last Reviewed: June 10, 1999