Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add 2nd Recipient & additonal CC Recipients to Lotus Notes E_mail code

Status
Not open for further replies.

Randy11

Technical User
Oct 4, 2002
175
CA
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
 
Try creating a variable that holds the list of the people to CC.

Example -

Names = Range("A1").value & ";"
Names = Names & Range("B1").value & ";"

I don't know if it will help but I posted something a while back about sending emails from VBA. Perhaps you can glean something off that link.

 
FYI, found a solution to this code inquiry....
Added
Dim recip(25) As Variant
Dim ccrecip(25) As Variant

recip(0) = "YoSmengy@smengy.com"
recip(1) = "HoSmengy@smengy.com"

ccrecip(0) = "JoSmengy@smengy.com"

oDoc.sendto = recip
oDoc.copyto = ccrecip

Located MS Access VB code solution at: Altered slightly with oDco vs MailDoc.sendto & copyto...

Hope this is helpful to others.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top