Lotus Notes email background processing and open new message.

P

PCLIVE

I'm using the code below as an example. This code appears to populate
various fields of a Lotus Notes email and then send it. Using this same
code example, I was wondering if anyone knows of a way to:
Once the fields have been populated (in the background, obviously), I'd like
to then open a physical email document (new message) with the fields
populated as specified in the code. Basically, I don't want the email to
automatically send. Instead, I'd like the email to be opened unsent, with
the specified fields populated.

Can this be done using this code?
Thanks.
Paul

Sub sendEmail()
Dim oSess As Object
Dim Maildb As Object
Dim MailDoc As Object
Dim oItem As Object
Dim flag As Boolean
Dim bodyMsg As String
Dim WasOpen As Integer

emailErr = False

Set oSess = CreateObject("Notes.NotesSession")
Set Maildb = oSess.GETDATABASE("", "")

If Maildb.IsOpen = True Then
WasOpen = 1 'Already open for mail
Else
WasOpen = 0
Call Maildb.openmail 'This will prompt you for password
End If

On Error Goto err_handler

Set MailDoc = Maildb.CREATEDOCUMENT
Set oItem = MailDoc.CREATERICHTEXTITEM("BODY")

' Building Message
bodyMsg = "This email was generated by Cupid V3.0." & vbCrLf & vbCrLf
bodyMsg = bodyMsg & "Warning! The attached file contains confidential
information. Any unauthorized review, use, or distribution is prohibited. "
bodyMsg = bodyMsg & "If you are not the intended recipient, please
contact the sender by reply e-mail and destroy all copies of the original
message."
With MailDoc
.Form = "Memo"
.subject = "NIR from " & divContact & " (" & divNumber & ")"
.sendto = emailAddress
.body = bodyMsg
.postdate = Date
.SaveMessageOnSend = True
End With

' Attaching new item file.
Call oItem.EmbedObject(1454, "", emailPath)
MailDoc.visable = True

' Sending Message
MailDoc.send False

exit_SendAttachment:
On Error Resume Next
Set oSess = Nothing
Set Maildb = Nothing
Set MailDoc = Nothing
Set oItem = Nothing

' Done
Exit Sub

err_handler:
emailErr = True
If Err.Number = 7225 Then
MsgBox "File doesn't exist"
Else
MsgBox Err.Number & " " & Err.Description
End If
On Error Goto exit_SendAttachment
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top