T
Tim
Ron, I found this and I've been able to get it to work (the way I need it to)
with Lotus Notes.
I know there have been many questions on this site about using Lotus Notes
so if it will help anyone else out there, tailor it to your needs
It would be great to have on your site, where I can refer back to it, often...
Thanks for all your assistance in the past, and in the future.
' Creates statement for employee and emails it to Data-Entry
Sub LotusMail()
' setting up various objects
Dim Maildb As Object
Dim UserName As String
Dim MailDbName As String
Dim MailDoc As Object
Dim attachME As Object
Dim Session As Object
Dim EmbedObj1 As Object
Dim recipient As String
Dim ccRecipient As String
Dim bccRecipient As String
Dim subject As String
Dim bodytext As String
Dim Attachment1 As String
' setting up all sending recipients
recipient = "data"
ccRecipient = ""
bccRecipient = ""
' Gets employye name and incident number to create subjest line
subject = "Statement for " & Sheets("Employee List").Range("N5").Value & "
for Incident " & Sheets("Employee List").Range("N7").Value
' Gets Statement created and puts in body of email
bodytext = ThisWorkbook.Worksheets("Employee List").Range("N4").Value
'// Lets check to see if form is filled in Min req =Recipient, Subject, Body
Text
If recipient = vbNullString Or subject = vbNullString Or bodytext =
vbNullString Then
MsgBox "Recipient, Subject and or Body Text is NOT SET!", vbCritical +
vbInformation
Exit Sub
End If
' creating a notes session
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
On Error Resume Next
Maildb.OPENMAIL
End If
Set MailDoc = Maildb.CreateDocument
MailDoc.form = "Memo"
' loading the lotus notes e-mail with the inputed data
With MailDoc
..sendto = recipient
..copyto = ccRecipient
..blindcopyto = bccRecipient
..subject = subject
..body = bodytext
End With
' saving message
MailDoc.SaveMessageOnSend = True
Attachment1 = ThisWorkbook.Worksheets("Data").Range("ad1").Value
If Attachment1 <> "" Then
Set attachME = MailDoc.CREATERICHTEXTITEM("Attachment1")
Set EmbedObj1 = attachME.EMBEDOBJECT(1454, "", Attachment1, "Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")
End If
' send e-mail !!!!
MailDoc.PostedDate = Now()
' if error in attachment or name of recipients
On Error GoTo errorhandler1
MailDoc.Send 0, recipient
Set Maildb = Nothing
Set MailDoc = Nothing
Set attachME = Nothing
Set Session = Nothing
Set EmbedObj1 = Nothing
'Unload Me
Exit Sub
' setting up the error message
errorhandler1:
MsgBox "Incorrect name supplied or the attachment has not attached," & _
"or your Lotus Notes has not opened correctly. Recommend you open up Lotus
Notes" & _
"to ensure the application runs correctly and that a vaild connection exists"
Set Maildb = Nothing
Set MailDoc = Nothing
Set attachME = Nothing
Set Session = Nothing
Set EmbedObj1 = Nothing
' unloading the userform
'Unload Me
End Sub
with Lotus Notes.
I know there have been many questions on this site about using Lotus Notes
so if it will help anyone else out there, tailor it to your needs
It would be great to have on your site, where I can refer back to it, often...
Thanks for all your assistance in the past, and in the future.
' Creates statement for employee and emails it to Data-Entry
Sub LotusMail()
' setting up various objects
Dim Maildb As Object
Dim UserName As String
Dim MailDbName As String
Dim MailDoc As Object
Dim attachME As Object
Dim Session As Object
Dim EmbedObj1 As Object
Dim recipient As String
Dim ccRecipient As String
Dim bccRecipient As String
Dim subject As String
Dim bodytext As String
Dim Attachment1 As String
' setting up all sending recipients
recipient = "data"
ccRecipient = ""
bccRecipient = ""
' Gets employye name and incident number to create subjest line
subject = "Statement for " & Sheets("Employee List").Range("N5").Value & "
for Incident " & Sheets("Employee List").Range("N7").Value
' Gets Statement created and puts in body of email
bodytext = ThisWorkbook.Worksheets("Employee List").Range("N4").Value
'// Lets check to see if form is filled in Min req =Recipient, Subject, Body
Text
If recipient = vbNullString Or subject = vbNullString Or bodytext =
vbNullString Then
MsgBox "Recipient, Subject and or Body Text is NOT SET!", vbCritical +
vbInformation
Exit Sub
End If
' creating a notes session
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
On Error Resume Next
Maildb.OPENMAIL
End If
Set MailDoc = Maildb.CreateDocument
MailDoc.form = "Memo"
' loading the lotus notes e-mail with the inputed data
With MailDoc
..sendto = recipient
..copyto = ccRecipient
..blindcopyto = bccRecipient
..subject = subject
..body = bodytext
End With
' saving message
MailDoc.SaveMessageOnSend = True
Attachment1 = ThisWorkbook.Worksheets("Data").Range("ad1").Value
If Attachment1 <> "" Then
Set attachME = MailDoc.CREATERICHTEXTITEM("Attachment1")
Set EmbedObj1 = attachME.EMBEDOBJECT(1454, "", Attachment1, "Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")
End If
' send e-mail !!!!
MailDoc.PostedDate = Now()
' if error in attachment or name of recipients
On Error GoTo errorhandler1
MailDoc.Send 0, recipient
Set Maildb = Nothing
Set MailDoc = Nothing
Set attachME = Nothing
Set Session = Nothing
Set EmbedObj1 = Nothing
'Unload Me
Exit Sub
' setting up the error message
errorhandler1:
MsgBox "Incorrect name supplied or the attachment has not attached," & _
"or your Lotus Notes has not opened correctly. Recommend you open up Lotus
Notes" & _
"to ensure the application runs correctly and that a vaild connection exists"
Set Maildb = Nothing
Set MailDoc = Nothing
Set attachME = Nothing
Set Session = Nothing
Set EmbedObj1 = Nothing
' unloading the userform
'Unload Me
End Sub