L
Larry
I'm trying to create a Command Button using a Module that
when click will open up Outlook and populate the To and
Subject Field.
Public Function SendOutlookMsg(strSubject As String, strTo
As String, strHTML As String, Optional intUseBCC As
Integer = 0) As Integer
' Function to send an email message using Outlook
' Inputs: Subject of the message
' List of valid "To" email addresses
' HTML for the body of the message
' Send using BCC flag (optional)
' Output: True if successful
Dim objOL As Object, ObjMail As Object
'Get a pointer to Outlook - late binding
SetobjOl = CreateObject("Outlook.Application")
' Create new email
Set ObjMail = objOL.CreateItem(olMailItem)
' Set the subject
If intUseBCC = True Then
ObjMail.BCC = strTo
Else
ObjMail.To = strTo
End If
' Insert the HTML of the message
ObjMail.HTMLbody = strHTML
' Display it
ObjMail.Display
' Done - clear objects
Set ObjMail = Nothing
Set objOL = Nothing
' Return True
SendOutlookMsg = True
SendOutlookMsg_Exit:
Exit Function
End Function
How do I get this to work?
Thanks,
Michelle
when click will open up Outlook and populate the To and
Subject Field.
Public Function SendOutlookMsg(strSubject As String, strTo
As String, strHTML As String, Optional intUseBCC As
Integer = 0) As Integer
' Function to send an email message using Outlook
' Inputs: Subject of the message
' List of valid "To" email addresses
' HTML for the body of the message
' Send using BCC flag (optional)
' Output: True if successful
Dim objOL As Object, ObjMail As Object
'Get a pointer to Outlook - late binding
SetobjOl = CreateObject("Outlook.Application")
' Create new email
Set ObjMail = objOL.CreateItem(olMailItem)
' Set the subject
If intUseBCC = True Then
ObjMail.BCC = strTo
Else
ObjMail.To = strTo
End If
' Insert the HTML of the message
ObjMail.HTMLbody = strHTML
' Display it
ObjMail.Display
' Done - clear objects
Set ObjMail = Nothing
Set objOL = Nothing
' Return True
SendOutlookMsg = True
SendOutlookMsg_Exit:
Exit Function
End Function
How do I get this to work?
Thanks,
Michelle