Sending email messages
Automatically generating email messages is useful for many purposes, particularly during customized event procedures. The following example code shows a typical procedure for setting properties of a NewMailMessage object. It uses constants in the AS_MAPIMSG_RECIP_TYPE and AS_MAPIMSG_SEND_FLAGS enumerations to set various properties of the message before sending it.
Sub SendEmailMessage() Dim oMessage Set oMessage = Client.NewMailMessage 'Recipients oMessage.Recipients.Add "",AS_MMRT_TO,"<recipient.name@anotherdomain.com>" oMessage.Recipients.Add "",AS_MMRT_CC,"<recipient.name@anotherdomain.com>" 'Sender oMessage.Originator.Address = "<sender.name@mydomain.com>" oMessage.Originator.Name = "Sender's Name" oMessage.Originator.Type = AS_MMRT_ORIG 'Subject oMessage.Subject = "The subject of the message" 'Body text oMessage.NoteText = "The body text of the message" 'Attachments oMessage.Attachments.Add "c:\temp\my.bmp", "" 'Send it with MAPI options and reset when done oMessage.Send AS_MMSF_LOGON_UI oMessage.Clean End Sub