Sorry to proliferate this subject! However the code I have found either sends the new message automatically saving it to Sent items, or doesn’t send and saves it to Drafts.
What my users required is that the new message is composed from their MS Access application (with recipients, subject, and default text) and opened in it’s own window for editing before the user sends it manually.
I attach my code below and should be grateful for any help and advice on how it should be adapted to leave the message open. Also, it would be helpful if you could explain how this works as I do not seem to need to set any special references (under Tools/References in the VBA window), but yet it compiles with no problems. I’m using Access 2003 and Windows XP pro.
Thanks in anticipation
Richard
Code:
Option Compare Database
Option Explicit
Public Sub SendNotesMail(Subject As String, attachment As String, recipient As String, bodytext As String, 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 users 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)
Set session = CreateObject("Notes.NotesSession")
’ session.Initialize ’ (“password”) ’ Not required when Notes is already running
UserName = session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
Set Maildb = session.GetDatabase("", MailDbName)
If Maildb.IsOpen = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.SendTo = recipient
MailDoc.Subject = Subject
MailDoc.body = bodytext
MailDoc.SAVEMESSAGEONSEND = saveit
If attachment <> "" Then
Set AttachME = MailDoc.CREATERICHTEXTITEM("Attachment")
Set EmbedObj = AttachME.EmbedObject(1454, "", attachment, "Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")
End If
'Save the message to the Draft folder:
MailDoc.Save True, True
‘’ 'Send the document (DON’T WANT TO SEND IT, JUST OPEN IT FOR EDITING)
‘’ MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items folder
‘’ MailDoc.SEND 0, Recipient
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set AttachME = Nothing
Set session = Nothing
Set EmbedObj = Nothing
End Sub