‘ Function: Outlook_SendEmail
‘
‘ Sends an email using Outlook.
‘
‘ Input Parameters:
‘
‘ strTo - The email address or Outlook contact to whom the email should be sent.
‘ strSubject - The email’s subject.
‘ strBody - The email’s body (this may of course include newline characters).
‘
‘ Output Parameters:
‘
‘ None.
‘
‘ Returns:
‘
‘ Not applicable. This is a sub, not a function.
‘
Sub Outlook_SendEmail(strTo, strSubject, strBody)
‘TODO: maybe add support for CC, BCC, etc?
‘Create an Outlook object
Dim Outlook ‘As New Outlook.Application
Set Outlook = CreateObject(”Outlook.Application”)
‘Create a new message
Dim Message ‘As Outlook.MailItem
Set Message = Outlook.CreateItem(0)
With Message
‘You can display the message To debug And see state
‘.Display
.Subject = Subject
.Body = TextBody
‘Set destination email address
.Recipients.Add (strTo)
‘Set sender address If specified.
‘Const olOriginator = 0
‘If Len(aFrom) > 0 Then .Recipients.Add(aFrom).Type = olOriginator
‘Send the message
.Send
End With
End Sub
Wednesday, December 16, 2009
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment