How to set SMTP header properties by using CDONTS

This article has been archived. It is offered "as is" and will no longer be updated.
Summary
You can use Collaboration Data Objects for NTS (CDONTS) to set more header information for messages that are created by using CDONTS. The Value property of the NewMail object lets you add more header information to the NewMail object in CDONTS. To add the new header to the CDONTS message, you must assign the string to which the header is being set to the correct header name.

To do this, use the following syntax:
CDONTSNewMailObject.Value("Header String") = "Value that the header is being set to"				
More information
To set the Reply-To property on a message that is sent by using CDONTS, follow these steps:
  1. Paste the following code sample into a Microsoft Visual Basic 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@wingtiptoys.com"     strTo = "Recipient@wingtiptoys.com"     strReply_To = "Reply-To<Reply_To@wingtiptoys.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 clean up CDONTS objects.         myCDONTSMail.Send strFrom, strTo, strSubject, strMessage     Set myCDONTSMail = NothingEnd Sub				
  2. Add a reference to the CDONTS library to the project.
You can set the Value property more than one time. Every time that you set the Value property, another header is generated that will 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
For more information, visit the following Microsoft Developer Network (MSDN) Web site:RFC 822
kbDSupport kbGrpMsg kbMsg kbCDO kbCDONTS kbVBp
Properties

Article ID: 233293 - Last Review: 01/11/2015 02:55:42 - Revision: 3.0

  • kbnosurvey kbarchive kbFAQ kbhowto kbmsg KB233293
Feedback