I am using the following code successfully behind a command button:
Private Sub cmdSend_Click()
On Error GoTo Err_cmdSend_Click
SendMessage (“FranklJ@sutterhealth.org”)
Exit_cmdSend_Click:
Exit Sub
Err_cmdSend_Click:
MsgBox Err.Description
Resume Exit_cmdSend_Click
End Sub
(See SENDMESSAGE function below)
I want to add a second recipient and I guess I am not using the ; in the right place??
SendMessage (“FranklJ@mycompany.org;LortonC@mycompany.org”)
I want both to appear on the “To” line.
What am I doing wrong?
Thank you as always !
Michael
***FUNCTION**
Private Sub SendMessage(Recip As String)
On Error GoTo Err_SendMessage_Click
Dim NameSpace As Object
Dim EmailSend As Object
Dim EmailApp As Object
Dim MYSTRING As String
Dim mySubject As String
Dim myBody As String
Dim mYRecipient As String
MYSTRING = “YOU MUST FILL IN ALL REQUIRED FIELDS. REQUESTER/SOURCE/HMO/IPA/GROUP# & PLAN”
If IsNull(cboRequester) Or IsNull(Combo779) Or IsNull([txtgroup#]) Or IsNull([cboSource]) Or IsNull(txtPlan) Then
MsgBox MYSTRING, vbExclamation, “DATA ENTRY ERROR”
Exit Sub
End If
mySubject = “ITCFM ” & “URGENT!!!!! ” & [HMO] & “/” & [IPA] & “/” & [Group Name] & “/” & [Group#]
myBody = “HMO: ” & [HMO] & Chr(10) & “IPA: ” & [IPA] & Chr(10) & “Group Name: ” & [Group Name] & Chr(10) & “Group#: ” & [Group#] & _
Chr(10) & “Plan Name: ” & [Plan] & Chr(10) & “Eff Date: ” & [EffDate] & Chr(10) & “IDX Plan#: ” & [IDX Plan#] & Chr(10) & “Contract Code/PPID: ” & _
[Contract Code (CC)] & Chr(10) & “Branch Code(Cigna):” & [txtBranchCode] & Chr(10) & “Benefit Option Code(Cigna):” & [txtBenefitOptionCode] & Chr(10) & _
“Unit #(Maxicare):” & [txtUnitNum] & Chr(10) & “Plan Description:” & [Plan Description] & Chr(10) & “OV CoPay: ” & [txtOVCoPay] & _
Chr(10) & Chr(10) & “COMMENTS:” & Chr(10) & _
[Notes_Comments] & Chr(10) & Chr(10) & Chr(10) & [Requester] ‘Add a comma and a zero here to send automatically
mYRecipient = Recip
Set EmailApp = CreateObject(“Outlook.Application”) ‘outlook object
Set NameSpace = EmailApp.GetNamespace(“MAPI”)
Set EmailSend = EmailApp.CreateItem(0) ‘CreateItem(0)Mail Item
EmailSend.Subject = mySubject ‘subject
EmailSend.Body = myBody ‘body
EmailSend.Recipients.Add (mYRecipient) ‘first add the email or user as a recipient
‘EmailSend.Importance = olImportanceHigh
EmailSend.Display ‘ Remove if you don’t want to view email before being sent.
[txtSentToIT] = Format(Date, “MM/DD/YYYY”)
Exit_SendMessage_Click:
Exit Sub
Err_SendMessage_Click:
MsgBox Err.Description
Resume Exit_SendMessage_Click
End Sub