Send Method (CDONTS NewMail Object)

The Send method sends the NewMail object to the specified recipients.

Syntax

objNewMail.Send( [From] [, To] [, Subject] [, Body] [, Importance] ) 
 
objNewMail
Required. This NewMail object.
From
Optional. String. The full messaging address to be identified as the sender.
To
Optional. String. A list of full messaging addresses of recipients. The individual recipient addresses are separated by semicolons.
Subject
Optional. String. The subject line for the message.
Body
Optional. IStream object or String. The text of the message.
Importance
Optional. Long. The importance associated with the message.

Remarks

The From, To, Subject, Body, and Importance parameters correspond to the From, To, Subject, Body, and Importance properties on the NewMail object.

If both the To property and the To parameter of the Send method are supplied, the NewMail object is sent to all recipients on both lists.

Only C/C++ and Java programs can use an IStream object for the Body parameter. They should pass an IUnknown object that returns an IStream interface in response to QueryInterface. Microsoft® Visual Basic® supports the IDispatch interface and not IUnknown, so it cannot use an IStream object.

The NewMail object becomes invalid upon successful completion of the Send method, and you cannot reuse it for another message. You should Set it to Nothing to release the memory. Attempted access to a sent NewMail object results in a return of CdoE_INVALID_OBJECT.

Example

This code fragment demonstrates a simple usage of the NewMail object and its Send method:

Dim myMail 
Set myMail = CreateObject("CDONTS.NewMail") 
myMail.From = "Example@Microsoft.com" 
myMail.To = "Someone@company.com" 
myMail.Subject = "Sample Message" 
myMail.Body = "This is a sample message." 
myMail.AttachFile "d:\sample.txt" 
myMail.Send 
Set myMail = Nothing