command to send an e-mail

P

Pietro

Hi,

I'm using the below command to send an e-mail,I need the message to open
before sending,so that i may put the To and CC fields.

The code is

Dim mess_body As String
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Dim a As String
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)


DoCmd.SelectObject acQuery, "Tier2 Current Month Report", True
Me.Requery
DoCmd.TransferSpreadsheet acExport, 8, "Tier2 Current Month Report",
"O:\XBOX\XBOX-Tier2\Customer Support\Source\Reports\Current Month Report.xls"


'Application.SetOption "Show Hidden Objects", False
'DoCmd.RunCommand acCmdWindowHide
' DoCmd.SelectObject acForm, "Main page", False
' DoCmd.Maximize

Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)

With MailOutLook
.BodyFormat = olFormatHTML
.to = ""
.CC = ""
.Subject = "Current Month Report"
.HTMLBody = "<P>Dear All<P>" & _
"<P>Kindly find attached Tier2 Current Month
Report</P>" & _
"<P>Best Regards<P>" & _
"Customer Support Tool</P>"



If Left(Me.Mail_Attachment_Path, 1) <> "<" Then
.Attachments.add (Me.Mail_Attachment_Path)

End If
Application.Echo False
DoCmd.SelectObject acTable, "", True
DoCmd.RunCommand acCmdWindowHide
Application.Echo True

'.DeleteAfterSubmit = True 'This would let Outlook send th
note without storing it in your sent bin
.Send
End With
'MsgBox MailOutLook.Body
Exit Sub



email_error:
MsgBox "An error was encountered." & vbCrLf & "The error message
is: " & Err.Description
Resume Error_out
Error_out:
 
A

Arvin Meyer [MVP]

Add a line immediately before the line:

..Send

so that it looks like:

..Display
..Send
 

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

Similar Threads


Top