N
naigy
Hi I have a form with information which I wish to export to an email. The
software we use at work is Lotus Notes and our email is incorporated into
this. I need to export this data to an email in the body section (not as an
attachment). I am using the code below. My problem is I can't work out how to
set the email address to send the infomation to manually (currently hard
coded into vba) and also instead of sending the email immediately leaving it
open for further editing (or giving the option to send as is or modify). Any
assistance how to achieve these two tasks would be greatly appreciated. I
think it will all be in modifying the last couple of lines. Just not sure
exactly how.
As a side note if I use a macro and attach the information in a file then it
opens up the email in notes in edit mode so this leads me to think that it
can be done it is just a matter of knowing the right command.
Any assistance is greatly appreciated.
Private Sub EmailButton_Click()
Dim attachment As String
Dim recipient As String
Dim bodytext As String
Dim saveit As Boolean
Dim Resolved As String
'This sub will send a mail and attachment if neccessary to the
'recipient including the body text.
'Requires that notes client is installed on the system.
'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
Dim Session As Object 'The notes session
'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 or using above password you can use other
mailboxes.
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr
(1, UserName, " "))) & ".nsf"
'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.IsOpen = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If
If Me.ResolvedOverPhone <> 0 Then Resolved = "Yes" Else Resolved = "No"
' Set contents of body of message
bodytext = "Hi. ... ... ... ..." & _
vbCrLf & vbCrLf & "Repairs Reference: " & Me.ID.Value & ... ... ... ... .
... ...
'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = recipient
MailDoc.Subject = "Please follow up with your Customer"
MailDoc.Body = bodytext
MailDoc.SAVEMESSAGEONSEND = saveit
'Send the document
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items
folder
MailDoc.SEND 0, "(e-mail address removed)"
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set Session = Nothing
End Sub
software we use at work is Lotus Notes and our email is incorporated into
this. I need to export this data to an email in the body section (not as an
attachment). I am using the code below. My problem is I can't work out how to
set the email address to send the infomation to manually (currently hard
coded into vba) and also instead of sending the email immediately leaving it
open for further editing (or giving the option to send as is or modify). Any
assistance how to achieve these two tasks would be greatly appreciated. I
think it will all be in modifying the last couple of lines. Just not sure
exactly how.
As a side note if I use a macro and attach the information in a file then it
opens up the email in notes in edit mode so this leads me to think that it
can be done it is just a matter of knowing the right command.
Any assistance is greatly appreciated.
Private Sub EmailButton_Click()
Dim attachment As String
Dim recipient As String
Dim bodytext As String
Dim saveit As Boolean
Dim Resolved As String
'This sub will send a mail and attachment if neccessary to the
'recipient including the body text.
'Requires that notes client is installed on the system.
'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
Dim Session As Object 'The notes session
'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 or using above password you can use other
mailboxes.
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr
(1, UserName, " "))) & ".nsf"
'Open the mail database in notes
Set Maildb = Session.GETDATABASE("", MailDbName)
If Maildb.IsOpen = True Then
'Already open for mail
Else
Maildb.OPENMAIL
End If
If Me.ResolvedOverPhone <> 0 Then Resolved = "Yes" Else Resolved = "No"
' Set contents of body of message
bodytext = "Hi. ... ... ... ..." & _
vbCrLf & vbCrLf & "Repairs Reference: " & Me.ID.Value & ... ... ... ... .
... ...
'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = recipient
MailDoc.Subject = "Please follow up with your Customer"
MailDoc.Body = bodytext
MailDoc.SAVEMESSAGEONSEND = saveit
'Send the document
MailDoc.PostedDate = Now() 'Gets the mail to appear in the sent items
folder
MailDoc.SEND 0, "(e-mail address removed)"
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set Session = Nothing
End Sub