Connecting Tech Pros Worldwide Forums | Help | Site Map

Email (Lotus Notes) Issues

Member
 
Join Date: Jul 2008
Posts: 33
#1: Jul 21 '08
When I use the sendobject to send emails from an Access DB to an email address, it automatically opens an email memo pad (I use Lotus Notes) requiring me to hit the "Send" button. I had hoped that Access would automatically send out the emails without requiring me to hit the "Send" each time I request it to send an email. Is there a way around this??

And how can I automate the sending of this email every 60 days?
Member
 
Join Date: Jul 2008
Posts: 33
#2: Jul 21 '08

re: Email (Lotus Notes) Issues


Ok I figured out how to solve this. But I am having another dilemma: how can I attach the results of a query, "qryAccessDate", to this email so that it shows up in the body of the email in HTML format. For instance with sendobjects this was how I accomplished the task:
Expand|Select|Wrap|Line Numbers
  1. DoCmd.SendObject acQuery, "qryPasswordsAboutToExpire", "HTML(*.html)", "MyBoss@aol.com", "", "", _
  2.                           "Users With Passwords About to Expire", "The Passwords of the following " & _
  3.                           "Users will expire within 5 days!", True, ""
  4.  
But my question is how is this done in Lotus Notes without using sendobject?

Here's code for a basic lotus notes email from an Access DB:

Expand|Select|Wrap|Line Numbers
  1. Public Sub SendNotesMail(Subject As String, Attachment As String, Recipient As String, BodyText As String, SaveIt As Boolean)
  2. 'This public sub will send a mail and attachment if neccessary to the recipient including the body text.
  3. 'Requires that notes client is installed on the system.
  4.  
  5. 'Set up the objects required for Automation into lotus notes
  6. Dim Maildb As Object 'The mail database
  7. Dim UserName As String 'The current users notes name
  8. Dim MailDbName As String 'THe current users notes mail database name
  9. Dim MailDoc As Object 'The mail document itself
  10. Dim AttachME As Object 'The attachment richtextfile object
  11. Dim Session As Object 'The notes session
  12. Dim EmbedObj As Object 'The embedded object (Attachment)
  13.  
  14. 'Start a session to notes
  15. Set Session = CreateObject("Notes.NotesSession")
  16.  
  17. 'Get the sessions username and then calculate the mail file name.
  18. 'You may or may not need this as for MailDBname with some systems you can pass an empty string
  19. UserName = Session.UserName
  20. MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
  21.  
  22. 'Open the mail database in notes
  23. Set Maildb = Session.GETDATABASE("", MailDbName)
  24. If Maildb.ISOPEN = True Then
  25. 'Already open for mail
  26. Else
  27. Maildb.OPENMAIL
  28. End If
  29.  
  30. 'Set up the new mail document
  31. Set MailDoc = Maildb.CREATEDOCUMENT
  32. MailDoc.Form = "Memo"
  33. MailDoc.sendto = Recipient
  34. MailDoc.Subject = Subject
  35. MailDoc.Body = BodyText
  36. MailDoc.SAVEMESSAGEONSEND = SaveIt
  37.  
  38. 'Set up the embedded object and attachment and attach it
  39. If Attachment <> "" Then
  40. Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
  41. Set EmbedObj = AttachME.EMBEDOBJECT(1454, "", Attachment, "Attachment")
  42. MailDoc.CREATERICHTEXTITEM ("Attachment")
  43. End If
  44.  
  45. 'Send the document
  46. MailDoc.Send 0, Recipient
  47.  
  48. 'Clean Up
  49. Set Maildb = Nothing
  50. Set MailDoc = Nothing
  51. Set AttachME = Nothing
  52. Set Session = Nothing
  53. Set EmbedObj = Nothing
  54. End Sub
  55.  
* Could someone also show me how to automate the sending of emails using the above code? I wish to send out emails every 60 days.
Reply