Using Form Information to send an e-mail. (1 Viewer)

Locopete99

Registered User.
Local time
Today, 08:56
Joined
Jul 11, 2016
Messages
163
Hi Guys,

I have the below code to send an e-mail. It's not a million miles away from the excel equivalent.

I'm looking to have a button on a Form to e-mail confirmation e-mails once something has been completed.

I would like to know if there is a way to insert a for field into the e-mail?

So, ideally the subject Would be "Request for [Part Number]"

and the body of the e-mail would be "Your request for [Part Number] has been successfully completed."

Obviously [Part Number] would be the form field and would pull through the part number for that record.


Code:
Public Sub SendLotusNotesMail(strMailTitle As String, strLotusNotesUserID As String, strTextBody As String, Optional strFileAttachment As String = "", Optional fSaveMailToTheSentFolder As Boolean = False)

Dim objAttachment As Object
Dim objMailDb As Object
Dim objMailDocument As Object
Dim objEmbedObject As Object
Dim objNotesSession As Object

Dim strMailDbName As String

On Error Resume Next

'Start objNotesSession in Lotus Notes
Set objNotesSession = CreateObject("Notes.NotesSession")

'Open the mail database in Lotus Notes
Set objMailDb = objNotesSession.GETDATABASE("", strMailDbName)
objMailDb.OPENMAIL

'Set up the new mail document
Set objMailDocument = objMailDb.CREATEDOCUMENT
objMailDocument.Form = "Memo"
objMailDocument.sendto = strLotusNotesUserID
objMailDocument.Subject = strMailTitle
objMailDocument.Body = strTextBody
objMailDocument.SAVEMESSAGEONSEND = fSaveMailToTheSentFolder

'Set up the embedded object and strFileAttachment and attach it
If strFileAttachment <> "" Then

Set objAttachment = objMailDocument.CreateRichTextItem("strFileAttachm ent")
Set objEmbedObject = objAttachment.EmbedObject(1454, "", strFileAttachment, "strFileAttachment")

End If

'Send the document
objMailDocument.SEND 0, strLotusNotesUserID

'Clean Up
Set objMailDb = Nothing
Set objMailDocument = Nothing
Set objAttachment = Nothing
Set objNotesSession = Nothing
Set objEmbedObject = Nothing

End Sub
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 08:56
Joined
Aug 30, 2003
Messages
36,140
In general, you concatenate:

"Request for " & Me.[Part Number]

presuming the code is in the same form as the part number.
 

Users who are viewing this thread

Top Bottom