Microsoft KB Archive/233293

= How to set SMTP header properties by using CDONTS =

Article ID: 233293

Article Last Modified on 6/21/2005

-

APPLIES TO


 * Microsoft Collaboration Data Objects 1.2 for NT Server

-



This article was previously published under Q233293



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:   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" 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 = Nothing End Sub

 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.

