Platform SDK: CDO 1.2.1 |
The Send method sends the NewMail object to the specified recipients.
objNewMail.Send( [From] [, To] [, Subject] [, Body] [, Importance] )
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 = "Example@microsoft.com" myMail.To = "Someone@microsoft.com" myMail.Subject = "Sample Message" myMail.Body = "This is a sample message." myMail.AttachFile "d:\sample.txt" myMail.Send Set myMail = Nothing