I have looked at a few different threads regarding auto sending reports using e-mail. I have found a method that works, through the use of ClickYes. It basically uses 3 functions, one to resume ClickYes, one to create and auto send an e-mail to specified people with a report attached, and one to then suspend ClickYes.
What I would like to do is that when a command button is pushed in Access, to have a new message pop up with the report attached and the To:, CC:, Subject:, Body, fields filled in. But...I want the user to be able to add to the body if they desire and then physically press send. For example, when I click on an e-mail hyperlink, a new message comes up with the To: address already filled in. In otherwords, I want the user to be able to "preview" the e-mail and edit if necessary before clicking send.
Below is the code I currently have if it helps. I tried to removed the .Send but not luck.
What I would like to do is that when a command button is pushed in Access, to have a new message pop up with the report attached and the To:, CC:, Subject:, Body, fields filled in. But...I want the user to be able to add to the body if they desire and then physically press send. For example, when I click on an e-mail hyperlink, a new message comes up with the To: address already filled in. In otherwords, I want the user to be able to "preview" the e-mail and edit if necessary before clicking send.
Below is the code I currently have if it helps. I tried to removed the .Send but not luck.
Code:
Public Sub SendTeamMessage(Optional AttachmentPath)
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment
' Create the Outlook session.
Set objOutlook = CreateObject("Outlook.Application")
' Create the message.
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
With objOutlookMsg
' Add the To recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("xyz@aol.com")
objOutlookRecip.Type = olTo
' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("xyz@yahoo.com")
objOutlookRecip.Type = olCC
' Set the Subject, Body, and Importance of the message.
.Subject = "This is an Automation test with Microsoft Outlook"
.Body = "This is a test." & vbCrLf & vbCrLf
' Add attachments to the message.
If Not IsMissing(AttachmentPath) Then
Set objOutlookAttach = .Attachments.Add(AttachmentPath)
End If
' Resolve each Recipient's name.
For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If
Next
'I tried removing this to keep from AutoSending but it didn't work, just opened and close outlook.
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
End Sub