Excel mailing via Lotus Notes

M

MTBer

I've used the search facilty and searched via googel and have found som
code that works for sending my email via lotus notes at work.
I moded it a little so my email receiptients are shown on th
spreadsheet face

-------------------------------------
Dim objNotesSession As Object
Dim objNotesMailFile As Object
Dim objNotesDocument As Object
Dim objNotesField As Object
Dim emailsendto(10) As Variant


Function SendMail()

On Error GoTo SendMailError

Required - Send to address
emailsendto(0) = Range("address1")
emailsendto(1) = Range("address2")

EMailSubject = "Auto Lotus Note"
'EMailBCCTo = "" '' Optional

''Establish Connection to Notes
Set objNotesSession = CreateObject("Notes.NotesSession")

''Establish Connection to Mail File
'' .GETDATABASE("SERVER", "FILE")
Set objNotesMailFile = objNotesSession.GETDATABASE("", "")
''Open Mail
objNotesMailFile.OPENMAIL

''Create New Memo
Set objNotesDocument = objNotesMailFile.CREATEDOCUMENT

''Create 'Subject Field'
Set objNotesField = objNotesDocument.APPENDITEMVALUE("Subject"
EMailSubject)

''Create 'Send To' Field
Set objNotesField = objNotesDocument.APPENDITEMVALUE("SendTo"
emailsendto)

''Create 'Copy To' Field
Set objNotesField = objNotesDocument.APPENDITEMVALUE("CopyTo"
EMailCCTo)

'''Create 'Blind Copy To' Field
'Set objNotesField = objNotesDocument.APPENDITEMVALUE("BlindCopyTo"
EMailBCCTo)

''Create 'Body' of memo
Set objNotesField = objNotesDocument.CREATERICHTEXTITEM("Body")

With objNotesField
.APPENDTEXT "This e-mail is generated by an automated process."
.ADDNEWLINE 1
.APPENDTEXT "Please follow established contact procedures shoul
you have any questions."
.ADDNEWLINE 2
End With

''Attach the file --1454 indicate a file attachment
objNotesField = objNotesField.EMBEDOBJECT(1454, ""
ActiveWorkbook.FullName)

''Send the e-mail
objNotesDocument.SEND (0)

objNotesDocument.PostedDate = Now()

''Release storage
Set objNotesSession = Nothing
Set bjNotesSession = Nothing
Set objNotesMailFile = Nothing
Set objNotesDocument = Nothing
Set objNotesField = Nothing


''Set return code
SendMail = True

Exit Function

SendMailError:
Msg = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description
MsgBox Msg, , "Error", Err.HelpFile, Err.HelpContext

SendMail = False

End Function

---------------------------------


Unfortunately this code doesn't leave a sent message in notes, and
have no way of knowing if the email has been sent, can anybody help m
get a mail appearing in my sent mail?

thank you,
Pau
 

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