This code works great for sending an e-mail from Excel to a single recipient. Need to be able to add additional recipients and also need to add 1 or more CC recipients. Assistance appreciated...
Thanks, Randy
Sub EmailUsingNotes()
Dim oSess As Object, oDB As Object, oDoc As Object
Dim oItem As Object, direct As Object
Dim Var As Variant, flag As Boolean
Set oSess = CreateObject("Notes.NotesSession")
Set oDB = oSess.GETDATABASE("", "")
Call oDB.OPENMAIL
flag = True
If Not (oDB.IsOpen) Then flag = oDB.Open("", "")
If Not flag Then
MsgBox "Can't open mail file: " & oDB.SERVER & " " & oDB.FILEPATH
GoTo exit_SendAttachment
End If
On Error GoTo err_handler
'Building the message
Set oDoc = oDB.CREATEDOCUMENT
Set oItem = oDoc.CREATERICHTEXTITEM("BODY")
oDoc.Form = "Memo"
oDoc.Subject = ActiveWorkbook.Name & " - User Name: " & Application.UserName '
oDoc.sendto = "YoSmengy@Smengy.com"
oDoc.Body = "The noted File has been updated"
oDoc.postdate = Date
oDoc.SaveMessageOnSend = True
'Setting up attachments
'Call oItem.EmbedObject(1454, "", "") 'Put the full path to any attachments here
oDoc.visable = True
oDoc.Send False
exit_SendAttachment:
On Error Resume Next
Set oSess = Nothing
Set oDB = Nothing
Set oDoc = Nothing
Set oItem = Nothing
Exit Sub
err_handler:
If Err.Number = 7225 Then
MsgBox "File doesn't exist"
Else
MsgBox Err.Number & " " & Err.Description
End If
On Error GoTo exit_SendAttachment
End Sub
Thanks, Randy
Sub EmailUsingNotes()
Dim oSess As Object, oDB As Object, oDoc As Object
Dim oItem As Object, direct As Object
Dim Var As Variant, flag As Boolean
Set oSess = CreateObject("Notes.NotesSession")
Set oDB = oSess.GETDATABASE("", "")
Call oDB.OPENMAIL
flag = True
If Not (oDB.IsOpen) Then flag = oDB.Open("", "")
If Not flag Then
MsgBox "Can't open mail file: " & oDB.SERVER & " " & oDB.FILEPATH
GoTo exit_SendAttachment
End If
On Error GoTo err_handler
'Building the message
Set oDoc = oDB.CREATEDOCUMENT
Set oItem = oDoc.CREATERICHTEXTITEM("BODY")
oDoc.Form = "Memo"
oDoc.Subject = ActiveWorkbook.Name & " - User Name: " & Application.UserName '
oDoc.sendto = "YoSmengy@Smengy.com"
oDoc.Body = "The noted File has been updated"
oDoc.postdate = Date
oDoc.SaveMessageOnSend = True
'Setting up attachments
'Call oItem.EmbedObject(1454, "", "") 'Put the full path to any attachments here
oDoc.visable = True
oDoc.Send False
exit_SendAttachment:
On Error Resume Next
Set oSess = Nothing
Set oDB = Nothing
Set oDoc = Nothing
Set oItem = Nothing
Exit Sub
err_handler:
If Err.Number = 7225 Then
MsgBox "File doesn't exist"
Else
MsgBox Err.Number & " " & Err.Description
End If
On Error GoTo exit_SendAttachment
End Sub