I am sending a message from Access 97 using Lotus Notes. Everything seems to work smoothly the only problem I have is with the TO and CC. The TO should be controlled by a combobox "Routed To"; if the user selects someone from this box that person will be in the TO, I have CC to default at a specific email address...Could someone please take a look at my code...
[tt]Private Sub Send_Click()
DoCmd.SendObject acSendNoObject, , , Route_To, "HRHelpDesk@siac.com", , ("This ticket has been routed by the HR Help Desk"
, ("Please contact the following employee: " & CallerName & " at : " & Telephone & ", after reviewing the following question: " & RequestedQuestion & " Thank you, " & UserName)
DoCmd.Close acForm, "HelpDeskCalls", acSaveYes
DoCmd.OpenForm "TicketOption"
End Sub[/tt]
This is my module:
[tt]Public Sub SendNotesMail(Subject As String, Attachment As String, Recipient As String, cc As String, BodyText As String, SaveIt As Boolean)
'Set up the objects required for Automation into lotus notes
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 NotesDocument
Dim MailDoc2 As Object
Dim AttachMe As Object 'The attachment richtextfile object
Dim session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object Attachment
Dim CurrentDatabase As String
Dim NotesSS As New NotesSession
Dim NotesDb As New NotesDatabase
Dim SendFolder As String
Dim view As NotesView
On Error GoTo Errshow:
NotesSS.Initialize '"password" ' you can place your password here to go straight in if not logged in already
With NotesSS
Set NotesDb = .GetDatabase("Mail3/SIAC", "mail/jperez.nsf", False)
End With
With NotesDb
'Start a session to notes
Set session = CreateObject("Notes.NotesSession"
'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string
UserName = session.UserName
MailDbName = NotesDb
Set MailDb = session.GetDatabase("", MailDbName)
If Not (MailDb.IsOpen) = True Then MailDb.OPENMAIL
'Set up the new mail document
Set MailDoc = MailDb.CreateDocument
With MailDoc
.Form = "Memo"
.sendto = Recipient
.CopyTo = cc
.Subject = Subject
.Body = BodyText
.SaveMessageOnSend = SaveIt
.principal = "user account" '(if different to your default account name)
'.PutInFolder SendFolder, True '(if you need a copy in the sent folder)
End With
'Set up the embedded object and attachment and attach it
If Attachment <> "" Then
Set AttachMe = MailDoc.CreateRichTextItem("Attachment"
Set EmbedObj = AttachMe.EmbedObject(1454, "", Attachment, "Attachment"
MailDoc.CreateRichTextItem ("Attachment"
End If
End With
'MailDoc.PutInFolder (SendFolder)
'Send the document
MailDoc.Send 1, Recipient
MsgBox "Sent!", vbExclamation
Cleanup:
Set MailDb = Nothing
Set MailDoc = Nothing
Set AttachMe = Nothing
Set session = Nothing
Set EmbedObj = Nothing
Exit Sub
Errshow:
MsgBox (Err.Description)
GoTo Cleanup
End Sub [/tt]
Guys I really need your help...I am so close I could taste it...
[tt]Private Sub Send_Click()
DoCmd.SendObject acSendNoObject, , , Route_To, "HRHelpDesk@siac.com", , ("This ticket has been routed by the HR Help Desk"
DoCmd.Close acForm, "HelpDeskCalls", acSaveYes
DoCmd.OpenForm "TicketOption"
End Sub[/tt]
This is my module:
[tt]Public Sub SendNotesMail(Subject As String, Attachment As String, Recipient As String, cc As String, BodyText As String, SaveIt As Boolean)
'Set up the objects required for Automation into lotus notes
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 NotesDocument
Dim MailDoc2 As Object
Dim AttachMe As Object 'The attachment richtextfile object
Dim session As Object 'The notes session
Dim EmbedObj As Object 'The embedded object Attachment
Dim CurrentDatabase As String
Dim NotesSS As New NotesSession
Dim NotesDb As New NotesDatabase
Dim SendFolder As String
Dim view As NotesView
On Error GoTo Errshow:
NotesSS.Initialize '"password" ' you can place your password here to go straight in if not logged in already
With NotesSS
Set NotesDb = .GetDatabase("Mail3/SIAC", "mail/jperez.nsf", False)
End With
With NotesDb
'Start a session to notes
Set session = CreateObject("Notes.NotesSession"
'Get the sessions username and then calculate the mail file name
'You may or may not need this as for MailDBname with some systems you
'can pass an empty string
UserName = session.UserName
MailDbName = NotesDb
Set MailDb = session.GetDatabase("", MailDbName)
If Not (MailDb.IsOpen) = True Then MailDb.OPENMAIL
'Set up the new mail document
Set MailDoc = MailDb.CreateDocument
With MailDoc
.Form = "Memo"
.sendto = Recipient
.CopyTo = cc
.Subject = Subject
.Body = BodyText
.SaveMessageOnSend = SaveIt
.principal = "user account" '(if different to your default account name)
'.PutInFolder SendFolder, True '(if you need a copy in the sent folder)
End With
'Set up the embedded object and attachment and attach it
If Attachment <> "" Then
Set AttachMe = MailDoc.CreateRichTextItem("Attachment"
Set EmbedObj = AttachMe.EmbedObject(1454, "", Attachment, "Attachment"
MailDoc.CreateRichTextItem ("Attachment"
End If
End With
'MailDoc.PutInFolder (SendFolder)
'Send the document
MailDoc.Send 1, Recipient
MsgBox "Sent!", vbExclamation
Cleanup:
Set MailDb = Nothing
Set MailDoc = Nothing
Set AttachMe = Nothing
Set session = Nothing
Set EmbedObj = Nothing
Exit Sub
Errshow:
MsgBox (Err.Description)
GoTo Cleanup
End Sub [/tt]
Guys I really need your help...I am so close I could taste it...