I’m using the code below that I obtained from http://www.ozgrid.com/forum/showthread.php?t=53713 to send email from excel but I have a small problem. The code send the email immediately whereas I wanted to view them first and initiate sending manually. I hope somebody can help me with this. Thanks in advance.
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.
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