Attachments with email from lotus

W

wpshop

I am trying to send a report through Lotus Notes. Can I send it in
snp format or does it have to be pdf? I am using the following code but I
don't know how to reference an Access report? Do I have to export it first
and then send the email through the db? I know by EMBED code is wrong. I've
been trying to find a flow that will work but haven't had any luck so far. I
pulled this code through several online sources and am so close to finishing!
any help you can give would be appreciated.

Private Sub SendNotesMail_Click()

'Set up the objects required for Automation into lotus notes
Dim Form As String
Dim sendto As String
Dim Subject As String
Dim Attachement As String
Dim Recipient As String
Dim BodyText As String
Dim SaveIt As Boolean
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'The current userse notes mail database name
Dim MailDoc 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)
'Start a notes session
Set Session = CreateObject("Lotus.NotesSession")
'Next line only works with 5.x and above. Replace password with your
password
Session.Initialize ("")
'Get the sessions username and then calculate the mail file name
'You may of may not need this as for MailDBName with some systems you
can pass an empty string or using above password you can use other mailboxes.
UserName = Session.UserName
Strt = Split(UserName, "=")(1)
Strt = Split(Strt, "/")(0)
WordArray = Left$(Strt, 1) & Right(Strt, (Len(Strt) - InStr(1, Strt, "
")))
MailDbName = "mail/" & WordArray
'Open the mail dtabase in notes
Set Maildb = Session.GETDATABASE("ABCD_LN01", MailDbName)

'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
Call MailDoc.REPLACEITEMVALUE("Form", "Memo")
Call MailDoc.REPLACEITEMVALUE("SendTo", "(e-mail address removed)")
Call MailDoc.REPLACEITEMVALUE("Subject", "HOT! TEST SUBJECT")
Set Body = MailDoc.CREATERICHTEXTITEM("Body")
Call Body.APPENDTEXT("Body text here")
Call Body.ADDNEWLINE(2)
Call Body.EMBEDOBJECT(1454, "", , "Monthly Report")
MailDoc.SAVEMESSAGEONSEND = True
'Send the document
Call MailDoc.REPLACEITEMVALUE("PostedDate", Now())
Call MailDoc.SEND(False)
'Clean up
Set Maildb = Nothing
Set MailDoc = Nothing
Set Body = Nothing
Set Session = Nothing
 
G

Graham Mandeno

You will need to export the report to a SNP or PDF file first (use
DoCmd.OutputTo to export to a SNP) and *then* add the resulting file as an
attachment to your email.

I don't know how to add attachments using Lotus Notes. Perhaps you should
post that question to a Lotus Notes forum.

Did you read my post in your previous thread cautioning you about the
potential problems of deriving the mailbox name from the user's full name?
 
W

wpshop

I did read your other post. Thank you! I am going to work on that as soon as
I get this attachment going. I am going to try PDF since it wouldn't attach
the .doc document. Do you know if I can attach excel documents? Thanks
again!

Graham Mandeno said:
You will need to export the report to a SNP or PDF file first (use
DoCmd.OutputTo to export to a SNP) and *then* add the resulting file as an
attachment to your email.

I don't know how to add attachments using Lotus Notes. Perhaps you should
post that question to a Lotus Notes forum.

Did you read my post in your previous thread cautioning you about the
potential problems of deriving the mailbox name from the user's full name?
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

wpshop said:
I am trying to send a report through Lotus Notes. Can I send it in
snp format or does it have to be pdf? I am using the following code but I
don't know how to reference an Access report? Do I have to export it
first
and then send the email through the db? I know by EMBED code is wrong.
I've
been trying to find a flow that will work but haven't had any luck so far.
I
pulled this code through several online sources and am so close to
finishing!
any help you can give would be appreciated.

Private Sub SendNotesMail_Click()

'Set up the objects required for Automation into lotus notes
Dim Form As String
Dim sendto As String
Dim Subject As String
Dim Attachement As String
Dim Recipient As String
Dim BodyText As String
Dim SaveIt As Boolean
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'The current userse notes mail database name
Dim MailDoc 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)
'Start a notes session
Set Session = CreateObject("Lotus.NotesSession")
'Next line only works with 5.x and above. Replace password with your
password
Session.Initialize ("")
'Get the sessions username and then calculate the mail file name
'You may of may not need this as for MailDBName with some systems you
can pass an empty string or using above password you can use other
mailboxes.
UserName = Session.UserName
Strt = Split(UserName, "=")(1)
Strt = Split(Strt, "/")(0)
WordArray = Left$(Strt, 1) & Right(Strt, (Len(Strt) - InStr(1, Strt, "
")))
MailDbName = "mail/" & WordArray
'Open the mail dtabase in notes
Set Maildb = Session.GETDATABASE("ABCD_LN01", MailDbName)

'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
Call MailDoc.REPLACEITEMVALUE("Form", "Memo")
Call MailDoc.REPLACEITEMVALUE("SendTo", "(e-mail address removed)")
Call MailDoc.REPLACEITEMVALUE("Subject", "HOT! TEST SUBJECT")
Set Body = MailDoc.CREATERICHTEXTITEM("Body")
Call Body.APPENDTEXT("Body text here")
Call Body.ADDNEWLINE(2)
Call Body.EMBEDOBJECT(1454, "", , "Monthly Report")
MailDoc.SAVEMESSAGEONSEND = True
'Send the document
Call MailDoc.REPLACEITEMVALUE("PostedDate", Now())
Call MailDoc.SEND(False)
'Clean up
Set Maildb = Nothing
Set MailDoc = Nothing
Set Body = Nothing
Set Session = Nothing
 
G

Graham Mandeno

You should be able to attach any sort of file. I suggest you ask in a Notes
forum. When you get the answer, you might like to post back here in case
the information benefits any other Access developers.

Actually, I just did a bit of Googling (sorry MS <g>) and found this:
http://www.fabalou.com/VBandVBA/lotusnotesmail.asp

It appears you have to use the CREATERICHTEXTITEM method again to create the
attachment:
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")

Here, the variable Attachment would be the full path to the file you want to
attach, the one you have presumably just created by exporting your report to
a PDF or SNP.
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

wpshop said:
I did read your other post. Thank you! I am going to work on that as soon
as
I get this attachment going. I am going to try PDF since it wouldn't
attach
the .doc document. Do you know if I can attach excel documents?
Thanks
again!

Graham Mandeno said:
You will need to export the report to a SNP or PDF file first (use
DoCmd.OutputTo to export to a SNP) and *then* add the resulting file as
an
attachment to your email.

I don't know how to add attachments using Lotus Notes. Perhaps you
should
post that question to a Lotus Notes forum.

Did you read my post in your previous thread cautioning you about the
potential problems of deriving the mailbox name from the user's full
name?
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

wpshop said:
I am trying to send a report through Lotus Notes. Can I send it in
snp format or does it have to be pdf? I am using the following code
but I
don't know how to reference an Access report? Do I have to export it
first
and then send the email through the db? I know by EMBED code is wrong.
I've
been trying to find a flow that will work but haven't had any luck so
far.
I
pulled this code through several online sources and am so close to
finishing!
any help you can give would be appreciated.

Private Sub SendNotesMail_Click()

'Set up the objects required for Automation into lotus notes
Dim Form As String
Dim sendto As String
Dim Subject As String
Dim Attachement As String
Dim Recipient As String
Dim BodyText As String
Dim SaveIt As Boolean
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'The current userse notes mail database
name
Dim MailDoc 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)
'Start a notes session
Set Session = CreateObject("Lotus.NotesSession")
'Next line only works with 5.x and above. Replace password with
your
password
Session.Initialize ("")
'Get the sessions username and then calculate the mail file name
'You may of may not need this as for MailDBName with some systems
you
can pass an empty string or using above password you can use other
mailboxes.
UserName = Session.UserName
Strt = Split(UserName, "=")(1)
Strt = Split(Strt, "/")(0)
WordArray = Left$(Strt, 1) & Right(Strt, (Len(Strt) - InStr(1, Strt,
"
")))
MailDbName = "mail/" & WordArray
'Open the mail dtabase in notes
Set Maildb = Session.GETDATABASE("ABCD_LN01", MailDbName)

'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
Call MailDoc.REPLACEITEMVALUE("Form", "Memo")
Call MailDoc.REPLACEITEMVALUE("SendTo", "(e-mail address removed)")
Call MailDoc.REPLACEITEMVALUE("Subject", "HOT! TEST SUBJECT")
Set Body = MailDoc.CREATERICHTEXTITEM("Body")
Call Body.APPENDTEXT("Body text here")
Call Body.ADDNEWLINE(2)
Call Body.EMBEDOBJECT(1454, "", , "Monthly Report")
MailDoc.SAVEMESSAGEONSEND = True
'Send the document
Call MailDoc.REPLACEITEMVALUE("PostedDate", Now())
Call MailDoc.SEND(False)
'Clean up
Set Maildb = Nothing
Set MailDoc = Nothing
Set Body = Nothing
Set Session = Nothing
 
M

mcescher

I did read your other post.  Thank you! I am going to work on that as soon as
I get this attachment going.   I am going to try PDF since it wouldn't attach
the .doc document.   Do you know if I can attach excel documents?    Thanks
again!

<snip>

As was mentioned before, you'll have to export your file
(PDF,SNP,XLS,DOC, etc...) and then send the mail. Here is some code
that has worked pretty well for me.

Hope this helps,
Chris M.


Public Sub SendMail( _
strPassword As String, _
strSubject As String, _
strBody As String, _
strAttachment As String, _
strTo As String, _
Optional strCC As String = "", _
Optional strBCC As String = "", _
Optional blnSave As Boolean = False, _
Optional strImportance As String = "2")

Dim domMailDoc As NotesDocument
Dim domMailDocs As NotesDocumentCollection
Dim domMaildb As NotesDatabase
Dim domSession As NotesSession 'The notes session
Dim domDBDir As NotesDbDirectory
Dim domRichTextItem As NotesRichTextItem
Dim domEmbeddedObject As NotesEmbeddedObject
Dim intAttachment As Integer
Dim astrAttachment() As String
On Error GoTo Error_SendMail
'Start a session to notes
Set domSession = CreateObject("Lotus.NotesSession")
domSession.Initialize (strPassword)
'Debug.Print domSession.UserName
Set domDBDir = domSession.GetDbDirectory(domSession.ServerName)
Set domMaildb = domDBDir.OpenMailDatabase
Set domMailDocs = domMaildb.AllDocuments
Set domMailDoc = domMaildb.CreateDocument
Call domMailDoc.AppendItemValue("Form", "Memo")
Call domMailDoc.AppendItemValue("SendTo", Split(strTo, ";"))
Call domMailDoc.AppendItemValue("CopyTo", Split(strCC, ";"))
Call domMailDoc.AppendItemValue("BlindCopyTo", Split(strBCC, ";"))
Call domMailDoc.AppendItemValue("Subject", strSubject)
Call domMailDoc.AppendItemValue("Body", strBody)
Call domMailDoc.AppendItemValue("Importance", strImportance)
domMailDoc.SaveMessageOnSend = blnSave
'Set up the embedded object and attachment and attach it
If strAttachment <> "" Then
astrAttachment = Split(strAttachment, ";")
For intAttachment = LBound(astrAttachment) To UBound
(astrAttachment)
Set domRichTextItem = domMailDoc.CreateRichTextItem
("Attachment" _
& CStr(intAttachment))
Set domEmbeddedObject = domRichTextItem.EmbedObject( _
EMBED_ATTACHMENT, "", astrAttachment(intAttachment),
"Attachment" _
& CStr(intAttachment))
Next intAttachment
End If
'Send the document
domMailDoc.Send 0
Set domEmbeddedObject = Nothing
Set domRichTextItem = Nothing
Set domMailDoc = Nothing
Set domMailDocs = Nothing
Set domMaildb = Nothing
Set domDBDir = Nothing
Set domSession = Nothing
Exit Sub
Error_SendMail:
MsgBox Err.Description
End Sub
 
W

wpshop

Well the email is sending now but the file won't attach!! Below is what I
have. Maybe I'm missing something.

'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
Call MailDoc.REPLACEITEMVALUE("Form", "Memo")
Call MailDoc.REPLACEITEMVALUE("SendTo", "(e-mail address removed)")
Call MailDoc.REPLACEITEMVALUE("Subject", "HOT! TEST SUBJECT")
Set Body = MailDoc.CREATERICHTEXTITEM("Body")
Call Body.APPENDTEXT("Body text here")
MailDoc.SAVEMESSAGEONSEND = True
'Set the embedded object and attachment and attach it
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("H:\Training\Monthly
Report.doc")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", "H:\Training\Monthly
Report.doc", "H:\Training\Monthly Report.doc")
MailDoc.CREATERICHTEXTITEM ("H:\Training\Monthly Report.doc")
End If

'Send the document
Call MailDoc.REPLACEITEMVALUE("PostedDate", Now())
Call MailDoc.SEND(False)
'Clean up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Body = Nothing
Set Session = Nothing
Set EmbedObj = Nothing


Graham Mandeno said:
You should be able to attach any sort of file. I suggest you ask in a Notes
forum. When you get the answer, you might like to post back here in case
the information benefits any other Access developers.

Actually, I just did a bit of Googling (sorry MS <g>) and found this:
http://www.fabalou.com/VBandVBA/lotusnotesmail.asp

It appears you have to use the CREATERICHTEXTITEM method again to create the
attachment:
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")

Here, the variable Attachment would be the full path to the file you want to
attach, the one you have presumably just created by exporting your report to
a PDF or SNP.
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

wpshop said:
I did read your other post. Thank you! I am going to work on that as soon
as
I get this attachment going. I am going to try PDF since it wouldn't
attach
the .doc document. Do you know if I can attach excel documents?
Thanks
again!

Graham Mandeno said:
You will need to export the report to a SNP or PDF file first (use
DoCmd.OutputTo to export to a SNP) and *then* add the resulting file as
an
attachment to your email.

I don't know how to add attachments using Lotus Notes. Perhaps you
should
post that question to a Lotus Notes forum.

Did you read my post in your previous thread cautioning you about the
potential problems of deriving the mailbox name from the user's full
name?
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

I am trying to send a report through Lotus Notes. Can I send it in
snp format or does it have to be pdf? I am using the following code
but I
don't know how to reference an Access report? Do I have to export it
first
and then send the email through the db? I know by EMBED code is wrong.
I've
been trying to find a flow that will work but haven't had any luck so
far.
I
pulled this code through several online sources and am so close to
finishing!
any help you can give would be appreciated.

Private Sub SendNotesMail_Click()

'Set up the objects required for Automation into lotus notes
Dim Form As String
Dim sendto As String
Dim Subject As String
Dim Attachement As String
Dim Recipient As String
Dim BodyText As String
Dim SaveIt As Boolean
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'The current userse notes mail database
name
Dim MailDoc 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)
'Start a notes session
Set Session = CreateObject("Lotus.NotesSession")
'Next line only works with 5.x and above. Replace password with
your
password
Session.Initialize ("")
'Get the sessions username and then calculate the mail file name
'You may of may not need this as for MailDBName with some systems
you
can pass an empty string or using above password you can use other
mailboxes.
UserName = Session.UserName
Strt = Split(UserName, "=")(1)
Strt = Split(Strt, "/")(0)
WordArray = Left$(Strt, 1) & Right(Strt, (Len(Strt) - InStr(1, Strt,
"
")))
MailDbName = "mail/" & WordArray
'Open the mail dtabase in notes
Set Maildb = Session.GETDATABASE("ABCD_LN01", MailDbName)

'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
Call MailDoc.REPLACEITEMVALUE("Form", "Memo")
Call MailDoc.REPLACEITEMVALUE("SendTo", "(e-mail address removed)")
Call MailDoc.REPLACEITEMVALUE("Subject", "HOT! TEST SUBJECT")
Set Body = MailDoc.CREATERICHTEXTITEM("Body")
Call Body.APPENDTEXT("Body text here")
Call Body.ADDNEWLINE(2)
Call Body.EMBEDOBJECT(1454, "", , "Monthly Report")
MailDoc.SAVEMESSAGEONSEND = True
'Send the document
Call MailDoc.REPLACEITEMVALUE("PostedDate", Now())
Call MailDoc.SEND(False)
'Clean up
Set Maildb = Nothing
Set MailDoc = Nothing
Set Body = Nothing
Set Session = Nothing
 
W

wpshop

Apparently it is ".docx" in 2007. It works now. Thank you for your
patience!!

wpshop said:
Well the email is sending now but the file won't attach!! Below is what I
have. Maybe I'm missing something.

'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
Call MailDoc.REPLACEITEMVALUE("Form", "Memo")
Call MailDoc.REPLACEITEMVALUE("SendTo", "(e-mail address removed)")
Call MailDoc.REPLACEITEMVALUE("Subject", "HOT! TEST SUBJECT")
Set Body = MailDoc.CREATERICHTEXTITEM("Body")
Call Body.APPENDTEXT("Body text here")
MailDoc.SAVEMESSAGEONSEND = True
'Set the embedded object and attachment and attach it
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("H:\Training\Monthly
Report.doc")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", "H:\Training\Monthly
Report.doc", "H:\Training\Monthly Report.doc")
MailDoc.CREATERICHTEXTITEM ("H:\Training\Monthly Report.doc")
End If

'Send the document
Call MailDoc.REPLACEITEMVALUE("PostedDate", Now())
Call MailDoc.SEND(False)
'Clean up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Body = Nothing
Set Session = Nothing
Set EmbedObj = Nothing


Graham Mandeno said:
You should be able to attach any sort of file. I suggest you ask in a Notes
forum. When you get the answer, you might like to post back here in case
the information benefits any other Access developers.

Actually, I just did a bit of Googling (sorry MS <g>) and found this:
http://www.fabalou.com/VBandVBA/lotusnotesmail.asp

It appears you have to use the CREATERICHTEXTITEM method again to create the
attachment:
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")

Here, the variable Attachment would be the full path to the file you want to
attach, the one you have presumably just created by exporting your report to
a PDF or SNP.
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

wpshop said:
I did read your other post. Thank you! I am going to work on that as soon
as
I get this attachment going. I am going to try PDF since it wouldn't
attach
the .doc document. Do you know if I can attach excel documents?
Thanks
again!

:

You will need to export the report to a SNP or PDF file first (use
DoCmd.OutputTo to export to a SNP) and *then* add the resulting file as
an
attachment to your email.

I don't know how to add attachments using Lotus Notes. Perhaps you
should
post that question to a Lotus Notes forum.

Did you read my post in your previous thread cautioning you about the
potential problems of deriving the mailbox name from the user's full
name?
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

I am trying to send a report through Lotus Notes. Can I send it in
snp format or does it have to be pdf? I am using the following code
but I
don't know how to reference an Access report? Do I have to export it
first
and then send the email through the db? I know by EMBED code is wrong.
I've
been trying to find a flow that will work but haven't had any luck so
far.
I
pulled this code through several online sources and am so close to
finishing!
any help you can give would be appreciated.

Private Sub SendNotesMail_Click()

'Set up the objects required for Automation into lotus notes
Dim Form As String
Dim sendto As String
Dim Subject As String
Dim Attachement As String
Dim Recipient As String
Dim BodyText As String
Dim SaveIt As Boolean
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'The current userse notes mail database
name
Dim MailDoc 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)
'Start a notes session
Set Session = CreateObject("Lotus.NotesSession")
'Next line only works with 5.x and above. Replace password with
your
password
Session.Initialize ("")
'Get the sessions username and then calculate the mail file name
'You may of may not need this as for MailDBName with some systems
you
can pass an empty string or using above password you can use other
mailboxes.
UserName = Session.UserName
Strt = Split(UserName, "=")(1)
Strt = Split(Strt, "/")(0)
WordArray = Left$(Strt, 1) & Right(Strt, (Len(Strt) - InStr(1, Strt,
"
")))
MailDbName = "mail/" & WordArray
'Open the mail dtabase in notes
Set Maildb = Session.GETDATABASE("ABCD_LN01", MailDbName)

'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
Call MailDoc.REPLACEITEMVALUE("Form", "Memo")
Call MailDoc.REPLACEITEMVALUE("SendTo", "(e-mail address removed)")
Call MailDoc.REPLACEITEMVALUE("Subject", "HOT! TEST SUBJECT")
Set Body = MailDoc.CREATERICHTEXTITEM("Body")
Call Body.APPENDTEXT("Body text here")
Call Body.ADDNEWLINE(2)
Call Body.EMBEDOBJECT(1454, "", , "Monthly Report")
MailDoc.SAVEMESSAGEONSEND = True
'Send the document
Call MailDoc.REPLACEITEMVALUE("PostedDate", Now())
Call MailDoc.SEND(False)
'Clean up
Set Maildb = Nothing
Set MailDoc = Nothing
Set Body = Nothing
Set Session = Nothing
 
G

Graham Mandeno

You're welcome! Glad you got it working!
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

wpshop said:
Apparently it is ".docx" in 2007. It works now. Thank you for your
patience!!

wpshop said:
Well the email is sending now but the file won't attach!! Below is what
I
have. Maybe I'm missing something.

'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
Call MailDoc.REPLACEITEMVALUE("Form", "Memo")
Call MailDoc.REPLACEITEMVALUE("SendTo", "(e-mail address removed)")
Call MailDoc.REPLACEITEMVALUE("Subject", "HOT! TEST SUBJECT")
Set Body = MailDoc.CREATERICHTEXTITEM("Body")
Call Body.APPENDTEXT("Body text here")
MailDoc.SAVEMESSAGEONSEND = True
'Set the embedded object and attachment and attach it
If Attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("H:\Training\Monthly
Report.doc")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "",
"H:\Training\Monthly
Report.doc", "H:\Training\Monthly Report.doc")
MailDoc.CREATERICHTEXTITEM ("H:\Training\Monthly Report.doc")
End If

'Send the document
Call MailDoc.REPLACEITEMVALUE("PostedDate", Now())
Call MailDoc.SEND(False)
'Clean up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set Body = Nothing
Set Session = Nothing
Set EmbedObj = Nothing


Graham Mandeno said:
You should be able to attach any sort of file. I suggest you ask in a
Notes
forum. When you get the answer, you might like to post back here in
case
the information benefits any other Access developers.

Actually, I just did a bit of Googling (sorry MS <g>) and found this:
http://www.fabalou.com/VBandVBA/lotusnotesmail.asp

It appears you have to use the CREATERICHTEXTITEM method again to
create the
attachment:
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment,
"Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")

Here, the variable Attachment would be the full path to the file you
want to
attach, the one you have presumably just created by exporting your
report to
a PDF or SNP.
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

I did read your other post. Thank you! I am going to work on that as
soon
as
I get this attachment going. I am going to try PDF since it
wouldn't
attach
the .doc document. Do you know if I can attach excel documents?
Thanks
again!

:

You will need to export the report to a SNP or PDF file first (use
DoCmd.OutputTo to export to a SNP) and *then* add the resulting file
as
an
attachment to your email.

I don't know how to add attachments using Lotus Notes. Perhaps you
should
post that question to a Lotus Notes forum.

Did you read my post in your previous thread cautioning you about
the
potential problems of deriving the mailbox name from the user's full
name?
--
Good Luck :)

Graham Mandeno [Access MVP]
Auckland, New Zealand

I am trying to send a report through Lotus Notes. Can I send it in
snp format or does it have to be pdf? I am using the following
code
but I
don't know how to reference an Access report? Do I have to export
it
first
and then send the email through the db? I know by EMBED code is
wrong.
I've
been trying to find a flow that will work but haven't had any luck
so
far.
I
pulled this code through several online sources and am so close to
finishing!
any help you can give would be appreciated.

Private Sub SendNotesMail_Click()

'Set up the objects required for Automation into lotus notes
Dim Form As String
Dim sendto As String
Dim Subject As String
Dim Attachement As String
Dim Recipient As String
Dim BodyText As String
Dim SaveIt As Boolean
Dim Maildb As Object 'The mail database
Dim UserName As String 'The current users notes name
Dim MailDbName As String 'The current userse notes mail
database
name
Dim MailDoc 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)
'Start a notes session
Set Session = CreateObject("Lotus.NotesSession")
'Next line only works with 5.x and above. Replace password
with
your
password
Session.Initialize ("")
'Get the sessions username and then calculate the mail file
name
'You may of may not need this as for MailDBName with some
systems
you
can pass an empty string or using above password you can use other
mailboxes.
UserName = Session.UserName
Strt = Split(UserName, "=")(1)
Strt = Split(Strt, "/")(0)
WordArray = Left$(Strt, 1) & Right(Strt, (Len(Strt) - InStr(1,
Strt,
"
")))
MailDbName = "mail/" & WordArray
'Open the mail dtabase in notes
Set Maildb = Session.GETDATABASE("ABCD_LN01", MailDbName)

'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
Call MailDoc.REPLACEITEMVALUE("Form", "Memo")
Call MailDoc.REPLACEITEMVALUE("SendTo", "(e-mail address removed)")
Call MailDoc.REPLACEITEMVALUE("Subject", "HOT! TEST SUBJECT")
Set Body = MailDoc.CREATERICHTEXTITEM("Body")
Call Body.APPENDTEXT("Body text here")
Call Body.ADDNEWLINE(2)
Call Body.EMBEDOBJECT(1454, "", , "Monthly Report")
MailDoc.SAVEMESSAGEONSEND = True
'Send the document
Call MailDoc.REPLACEITEMVALUE("PostedDate", Now())
Call MailDoc.SEND(False)
'Clean up
Set Maildb = Nothing
Set MailDoc = Nothing
Set Body = Nothing
Set Session = Nothing
 

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