Lotus Notes email

kathleen

Active Member
Joined
Dec 16, 2002
Messages
295
Hi all, attempting to use some more Lotus Notes Code of Nates and am running into a problem. I cannot get it to cc: multiple people. Anyone know of a way? Thanks for your help



Sub SendMail()

Sheets("Menu").Select
Range("e5").Select
whatFile = ActiveCell.Value

Range("a5").Select
whatMonth = ActiveCell.Value

ExcelFileName = "Testing " & whatFile & " " & whatMonth

Dim Maildb As Object, MailDoc As Object, AttachMe As Object, Session As Object
Dim UserName As String, MailDbName As String
Dim EmbedObj1 As Object

Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, _
(Len(UserName) - InStr(1, UserName, " "))) & ".nsf"

Set Maildb = Session.GetDataBase(vbNullString, MailDbName)

If Not Maildb.IsOpen Then Maildb.OpenMail

Set MailDoc = Maildb.CreateDocument

MailDoc.Form = "Memo"
MailDoc.SendTo = "me@somewhere.com"
MailDoc.CopyTo = "you@somewhere.com, urmama@somewhere.com"

'MailDoc.BlindCopyTo = "bccRecipient"

MailDoc.Subject = whatFile & " Purchases for " & whatMonth 'Subject of e-mail


MailDoc.Body = "Hello, " & vbNewLine & vbNewLine & "Attached is the " & whatFile & _
" Manifest File for " & whatMonth & vbNewLine & vbNewLine

Set AttachMe = MailDoc.CreateRichTextItem("Attachment")
Set EmbedObj1 = AttachMe.Embedobject(1454, vbNullString, _
"C:\Manifests\" & ExcelFileName & ".xls", "Attachment") 'Attaches file to e-mail

MailDoc.SaveMessageOnSend = True
MailDoc.PostedDate = Now

On Error GoTo ErrorCheck
Call MailDoc.Send(False)

Exit Sub

Set EmbedObj1 = Nothing: Set AttachMe = Nothing: Set MailDoc = Nothing
Set Maildb = Nothing: Set Session = Nothing

ErrorCheck:
Set EmbedObj1 = Nothing: Set AttachMe = Nothing: Set MailDoc = Nothing
Set Maildb = Nothing: Set Session = Nothing

End Sub
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
Kathleen -

Add or Change a sheet name on your workbook to E-Mail Addresses.

A2-A25 Put you primary email addresses
B2-B25 Put your CC email addresses.

Try something like this:

Sub Button66_Click()
' Declare Variables for file and macro setup
Dim UserName As String
Dim MailDbName As String
Dim Maildb As Object
Dim MailDoc As Object
Dim AttachME As Object
Dim Session As Object
Dim EmbedObj1 As Object
' Open and locate current LOTUS NOTES User
Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
Set Maildb = Session.GetDataBase("", MailDbName)
If Maildb.IsOpen = True Then
Else
Maildb.OPENMAIL
End If
' Create New Mail and Address Title Handlers
Set MailDoc = Maildb.CreateDocument
MailDoc.Form = "Memo"
' Select range of e-mail addresses
Recipient = Sheets("E-Mail Addresses").Range("A2:A25").Value
MailDoc.SendTo = Recipient
ans = MsgBox("Would you like to Copy (cc) anyone on this message?" _
, vbQuestion & vbYesNo, "Send Copy")
If ans = vbYes Then
ccRecipient = Sheets("E-Mail Addresses").Range("B2:B25").Value
MailDoc.CopyTo = ccRecipient
End If
MailDoc.Subject = "WhatEver"
MailDoc.Body = _
"Enjoy"
' Select Workbook to Attach to E-Mail
MailDoc.SaveMessageOnSend = True
'attachment1 = "Your File" ' Required File Name
If attachment1 <> "" Then
On Error Resume Next
' Set AttachME = MailDoc.
' Set EmbedObj1 = AttachME.embedobject(1454, "attachment1",
On Error Resume Next
End If
MailDoc.PostedDate = Now()
On Error GoTo errorhandler1
MailDoc.Send 0, Recipient
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj1 = Nothing
errorhandler1:
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Session = Nothing
Set EmbedObj1 = Nothing
With Application
.ScreenUpdating = True
.DisplayAlerts = True
End With
End Sub



Kurt
 
Upvote 0
Thanks for both suggestions. Kevin I tried yours before I posted, no results, Stapuf thanks but I do not want to have the user presented with a dialog box, message box etc.

These address's are fairly static and do not change.

Anyway you can think of by adding into code.
 
Upvote 0
Kathleen -

Slice and dice the code as you need. I do not use the message box either. Glad the range idea worked for you.


Kurt
 
Upvote 0
Hello, I'm late, but like using a range, try passing an array, e.g.,

MailDoc.CopyTo = array("you@somewhere.com","urmama@somewhere.com")
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,192
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top