lotus notes email

J

jpb

Looking to send reports and attachments using lotus notes email directly (if
using the send.object command lotus notes open the message OK but waits for
user to manually send the message). Looking to send automatically.

This code works for sending the body of the message.
How to send a report or excel file as an attachment?

Thanks



Private Sub Command9_Click()

Dim notesdb As Object
Dim notesdoc As Object
Dim notesrtf As Object
Dim notessession As Object
Set notessession = CreateObject("Notes.Notessession")
Set notesdb = notessession.GETDATABASE("", "")
Call notesdb.OPENMAIL
Rem make new mail message
Set notesdoc = notesdb.CREATEDOCUMENT
'Call notesdoc.replaceitemvalue("Sendto", strSupportEMail)
Call notesdoc.ReplaceItemValue("Sendto", "86927")
Call notesdoc.ReplaceItemValue("Subject", "Problem Report")
Set notesrtf = notesdoc.CREATERICHTEXTITEM("body")
Call notesrtf.APPENDTEXT("Problem Report")
Call notesrtf.ADDNEWLINE(2)
's = ActiveDocument.Path + "\" + ActiveDocument.Name
'Call notesrtf.embedObject(1454, "", strCurrentPath, "Mail.rtf")
'Call notesrtf.EMBEDOBJECT(1454, "", strCurrentPath, "c:\temp\test.xls")
Rem send message
Call notesdoc.SEND(False)
Set notessession = Nothing

End Sub
 
M

mikearelli

This subroutine works for me.

I create the email's Subject, Attachments, Body, Header, Footer, and
Recipient list in another module, then use this one to actually send the
email.

Good Luck.

Sub SendNotesMail(Subject As String, Attachment As String, BodyText As
String, SaveIt As Boolean, _
strHeader As String, strFooter As String, Rec1 As String, Rec2 As
String, Rec3 As String, Rec4 As String, _
Rec5 As String, Rec6 As String)
On Error GoTo Email_Err

'Set up the objects required for Automation into lotus notes
Dim Maildb As Object 'The mail database
Dim MailDbName As String 'The current users notes mail database name
Dim MailFile As Object 'The mail document itself
Dim AttachME As Object 'The attachment richtextfile object
Dim Session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object (Attachment)
Dim RichStyle As Object
Dim rtitem As Object
Dim Recipients(1 To 6) As String

'Start a session to Lotus Notes
Set Session = CreateObject("Notes.NotesSession")
MailDbName = "YourMailDBName"
'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.ISOPEN = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If
'Set up the new mail document
Set MailFile = Maildb.CREATEDOCUMENT
MailFile.Form = "Memo"
Set RichStyle = Session.CREATERICHTEXTSTYLE
RichStyle.NOTESFONT = 4
'Reduce the Font Size if necessary
'RichStyle.FontSize = 8
Set rtitem = MailFile.CREATERICHTEXTITEM("Body")
Call rtitem.APPENDSTYLE(RichStyle)
Call rtitem.APPENDTEXT(strHeader)
Call rtitem.APPENDTEXT(BodyText)
Call rtitem.APPENDTEXT(strFooter)
Recipients(1) = Rec1
Recipients(2) = Rec2
Recipients(3) = Rec3
Recipients(4) = Rec4
Recipients(5) = Rec5
Recipients(6) = Rec6
MailFile.Subject = Subject
MailFile.SAVEMESSAGEONSEND = SaveIt
'Set up the embedded object and attachment and attach it
If Attachment <> "" Then
Set AttachME = MailFile.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment,
"Attachment")
End If
'Send the file
MailFile.SEND 0, Recipients
SendNotesMail_Exit:
'Clear variables to free up memory
Set Maildb = Nothing: Set MailFile = Nothing: Set AttachME = Nothing
Set Session = Nothing: Set EmbedObj = Nothing: Set rtitem = Nothing
Set RichStyle = Nothing

Exit Sub

Email_Err:
MsgBox Err.Number & ": " & Err.Description
Resume SendNotesMail_Exit

End Sub
 
J

jpb

Mike,

I got something to work using the code below. However, how do I pull the
addresses from a Access table then send using the code below?


Private Sub Command9_Click()

Dim notesdb As Object
Dim notesdoc As Object
Dim notesrtf As Object
Dim notessession As Object


Dim recip(25) As Variant
recip(0) = "(e-mail address removed)"
recip(1) = "(e-mail address removed)"
recip(2) = "(e-mail address removed)"


Set notessession = CreateObject("Notes.Notessession")
Set notesdb = notessession.GETDATABASE("", "")
Call notesdb.OPENMAIL
Rem make new mail message
Set notesdoc = notesdb.CREATEDOCUMENT
Call notesdoc.REPLACEITEMVALUE("Sendto", recip)
'Call notesdoc.REPLACEITEMVALUE("Sendto", "IDxxxxxx")
Call notesdoc.REPLACEITEMVALUE("Subject", "TEST automated MPM report")
Set notesrtf = notesdoc.CREATERICHTEXTITEM("body")
Call notesrtf.APPENDTEXT("Latest open order and receipt reports TEST TEST")
Call notesrtf.ADDNEWLINE(2)
's = ActiveDocument.Path + "\" + ActiveDocument.Name
'Call notesrtf.EMBEDOBJECT(1454, "", strCurrentPath,
GetFileName(strCurrentPath))
Call notesrtf.EMBEDOBJECT(1454, "", "c:\temp\test document.rtf")
Call notesrtf.ADDNEWLINE(2)
Call notesrtf.EMBEDOBJECT(1454, "", "c:\temp\test.xls")

Rem send message
Call notesdoc.SEND(False)
Set notessession = Nothing

End Sub
 
T

T-4000

what is lotus notes email
jpb said:
Mike,

I got something to work using the code below. However, how do I pull the
addresses from a Access table then send using the code below?


Private Sub Command9_Click()

Dim notesdb As Object
Dim notesdoc As Object
Dim notesrtf As Object
Dim notessession As Object


Dim recip(25) As Variant
recip(0) = "(e-mail address removed)"
recip(1) = "(e-mail address removed)"
recip(2) = "(e-mail address removed)"


Set notessession = CreateObject("Notes.Notessession")
Set notesdb = notessession.GETDATABASE("", "")
Call notesdb.OPENMAIL
Rem make new mail message
Set notesdoc = notesdb.CREATEDOCUMENT
Call notesdoc.REPLACEITEMVALUE("Sendto", recip)
'Call notesdoc.REPLACEITEMVALUE("Sendto", "IDxxxxxx")
Call notesdoc.REPLACEITEMVALUE("Subject", "TEST automated MPM report")
Set notesrtf = notesdoc.CREATERICHTEXTITEM("body")
Call notesrtf.APPENDTEXT("Latest open order and receipt reports TEST
TEST")
Call notesrtf.ADDNEWLINE(2)
's = ActiveDocument.Path + "\" + ActiveDocument.Name
'Call notesrtf.EMBEDOBJECT(1454, "", strCurrentPath,
GetFileName(strCurrentPath))
Call notesrtf.EMBEDOBJECT(1454, "", "c:\temp\test document.rtf")
Call notesrtf.ADDNEWLINE(2)
Call notesrtf.EMBEDOBJECT(1454, "", "c:\temp\test.xls")

Rem send message
Call notesdoc.SEND(False)
Set notessession = Nothing

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top