First off... Virgin post.
Next. Okay, so I tried to put it all in the title. I'm currently creating a database that will help to automate follow up emails. The user will select fields, and upon completion, click a button that will save the record and generate an email in Lotus Notes. All of this information is coming from one single form and storing to one single table.
Currently, some code I found on here courtesy of jmeadows7 is working great at creating and sending the email. However, here are my main problems with said code:
1) The "Memo" that is created is a completely clean memo. It doesn't use the user's preferences to generate the document. This means it lacks the signature of the user, as well as any other text (in the nature of our work, its common to have confidentiality notices) that they have set to be sent in every email. There will be multiple users, so using a file path to select an attachment/rtf isn't an option.
2) The email sends without opening. That is where we will eventually take it I would assume, but while in the development process, I would like the generated email to be user sent so it can reviewed before sending.
I have explored using a Macro that feeds from a temporary query/report, but the emails need to be personal, which is easier to do with VB coding. Maybe a combination is the answer?
Lotus Notes is the company wide email program, so it will always be open and set as the default mail client.
Let me know if there is something else you need to know. Here is the code I'm currently using (apologize for the eye sore, haven't cleaned it up yet):
and finally the original thread I jacked it from:
Thanks!
Next. Okay, so I tried to put it all in the title. I'm currently creating a database that will help to automate follow up emails. The user will select fields, and upon completion, click a button that will save the record and generate an email in Lotus Notes. All of this information is coming from one single form and storing to one single table.
Currently, some code I found on here courtesy of jmeadows7 is working great at creating and sending the email. However, here are my main problems with said code:
1) The "Memo" that is created is a completely clean memo. It doesn't use the user's preferences to generate the document. This means it lacks the signature of the user, as well as any other text (in the nature of our work, its common to have confidentiality notices) that they have set to be sent in every email. There will be multiple users, so using a file path to select an attachment/rtf isn't an option.
2) The email sends without opening. That is where we will eventually take it I would assume, but while in the development process, I would like the generated email to be user sent so it can reviewed before sending.
I have explored using a Macro that feeds from a temporary query/report, but the emails need to be personal, which is easier to do with VB coding. Maybe a combination is the answer?
Lotus Notes is the company wide email program, so it will always be open and set as the default mail client.
Let me know if there is something else you need to know. Here is the code I'm currently using (apologize for the eye sore, haven't cleaned it up yet):
Code:
'Generate Email
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
Dim BodyText As String
'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 = 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
'Body of email. Chr(13) Starts new line. Chr(45) is hyphen. Chr(149) is bullet.
BodyText = "The following have outstanding requirements: " & Chr(13) & Chr(13)
BodyText = BodyText & Chr(9) & Me.LABEL.Value & " " & Chr(45) & " " & Me.LABEL.Value & Chr(13)
'Determine how many missing items there are and list them as bullets
If IsNull(Me.MissingItem2.Value) = True Then
BodyText = BodyText & Chr(9) & Chr(9) & Chr(149) & " " & Me.MissingItem1.Value & Chr(13)
ElseIf IsNull(Me.MissingItem3.Value) = True Then
BodyText = BodyText & Chr(9) & Chr(9) & Chr(149) & " " & Me.MissingItem1.Value & Chr(13)
BodyText = BodyText & Chr(9) & Chr(9) & Chr(149) & " " & Me.MissingItem2.Value & Chr(13)
Else
BodyText = BodyText & Chr(9) & Chr(9) & Chr(149) & " " & Me.MissingItem1.Value & Chr(13)
BodyText = BodyText & Chr(9) & Chr(9) & Chr(149) & " " & Me.MissingItem2.Value & Chr(13)
BodyText = BodyText & Chr(9) & Chr(9) & Chr(149) & " " & Me.MissingItem3.Value & Chr(13)
End If
BodyText = BodyText & Chr(9) & "Thanks!"
'Set up the new mail document
Set MailDoc = Maildb.CREATEDOCUMENT
MailDoc.Form = "Memo"
MailDoc.sendto = "Email Address Here"
MailDoc.Subject = Subject
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, Recipient
'Clean Up
Set Maildb = Nothing
Set MailDoc = Nothing
Set Session = Nothing
and finally the original thread I jacked it from:
Thanks!