Send Method (CDONTS NewMail Object)

Send Method (CDONTS NewMail Object)

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


        objNewMail.Send( [From] [, To] [, Subject] [, Body] [, Importance] ) 


Required. This NewMail object.


Optional. String. The full messaging address to be identified as the sender.


Optional. String. A list of full messaging addresses of recipients. The individual recipient addresses are separated by semicolons.


Optional. String. The subject line for the message.


Optional. IStream object or String. The text of the message.


Optional. Long. The importance associated with the message.


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.


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

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

See Also


NewMail Object (CDONTS Library)