By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,479 Members | 988 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,479 IT Pros & Developers. It's quick & easy.

Send email message via lotus notes with 2 attachments from Access

P: 5
OS: Windows XP Professional
Access 2003
Lotus Notes 7

I am trying to send a email message from Access that will have 2 attachments that are excel versions of 2 separate queries.

I can send 1 attachment using the "sendObject" macro but it is not flexible enough to accept 2 attachments.

The twist on all of this is i need to use Notes as my email client as that is what my department uses.

Any hints or tips on where to start would be greatly appreciated.

Mike
Sep 3 '07 #1
Share this Question
Share on Google+
3 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
Hi Mike,

Try this code ...

Expand|Select|Wrap|Line Numbers
  1. Public Sub SendNotesMail()
  2. Dim notesDb As Object 'The mail database
  3. Dim UserName As String 'The current users notes name
  4. Dim notesDbName As String 'THe current users notes mail database name
  5. Dim notesDoc As Object 'The mail document itself
  6. Dim notesRtf As Object 'The attachment richtextfile object
  7. Dim notesSession As Object 'The notes session
  8. Dim EmbedObj As Object 'The embedded object (Attachment)
  9. Dim attach1 As String
  10. Dim attach2 As String
  11.  
  12.     'Start a session to notes
  13.     Set notesSession = CreateObject("Notes.NotesSession")
  14.  
  15.     'Get the sessions username and then calculate the mail file name
  16.     'You may or may not need this as for notesDBname with some systems you
  17.     'can pass an empty string
  18.     UserName = Session.UserName
  19.     notesDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
  20.  
  21.     'Open the mail database in notes
  22.     Set notesDb = Session.GETDATABASE("", notesDbName)
  23.  
  24.     If notesDb.IsOpen = False Then
  25.          notesDb.OPENMAIL
  26.     End If
  27.  
  28.     'Set up the new mail document
  29.     Set notesDoc = Maildb.CREATEDOCUMENT
  30.     notesDoc.Form = "Memo"
  31.     notesDoc.sendto = "someone@somewhere.com"
  32.     notesDoc.Subject = "Title goes here"
  33.     notesDoc.Body = "User Text............"
  34.     notesDoc.SAVEMESSAGEONSEND = False
  35.  
  36.     'Set up the embedded object and attachment and attach it
  37.     attach1 = "C:\excelfile1.xls"
  38.     Set notesRtf = notesDoc.CREATERICHTEXTITEM("Attachment")
  39.     Set EmbedObj = notesRtf.EMBEDOBJECT(1454, "", attach1, "Attachment")
  40.     MailDoc.CREATERICHTEXTITEM ("Attachment")
  41.  
  42.     attach2 = "C:\excelfile2.xls"
  43.     Set notesRtf = notesDoc.CREATERICHTEXTITEM("Attachment")
  44.     Set EmbedObj = notesRtf.EMBEDOBJECT(1454, "", attach2, "Attachment")
  45.     MailDoc.CREATERICHTEXTITEM ("Attachment")
  46.  
  47.     'Send the document
  48.     notesDoc.SEND 0, Recipient
  49.  
  50.     'Clean Up
  51.     Set notesDb = Nothing
  52.     Set notesDoc = Nothing
  53.     Set notesRtf = Nothing
  54.     Set notesSession = Nothing
  55.     Set EmbedObj = Nothing
  56.  
  57. End Sub
  58.  
Sep 5 '07 #2

P: 5
Thanks for the reply, i get an error on line 29

Runtime error 424
Object required

....help????


thanks

Mike
Sep 10 '07 #3

MMcCarthy
Expert Mod 10K+
P: 14,534
Sorry Mike, my fault.

Change the line to ...

Set notesDoc = notesDb.CREATEDOCUMENT
Sep 10 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.