Email Question

S

Stockwell43

Hello,

I have a button that when clicked will send an email to the floor managers.
What I would like to know is:

Is there a way to have the email return a read receipt without having to
manually select on every email? So when the button from the form is clicked
and the email pops up with the information from the current record, the read
receipt is already selected?

Thanks!!!
 
T

Tom Wickerath

Hi Stockwell,
Is there a way to have the email return a read receipt without having to
manually select on every email?

Yes, as long as you are using Outlook as your e-mail client and not Outlook
Express. See this article:

Using Automation in Microsoft Office Access 2003 to
Work with Microsoft Office Outlook 2003
http://msdn.microsoft.com/en-us/library/aa159619(office.11).aspx

The code in this MSDN article is a bit messed up, so I fixed it and pasted
the fixed version below (specifically, there were two errors in the code). In
addition, I added the line of code ".ReadReceiptRequested = True" (marked
below with a arrow comment). This version has hard-coded To and CC names, so
you may need to modify the procedure to allow you to pass in the appropriate
e-mail addresses as input parameters.

Option Compare Database
Option Explicit

Sub sbSendMessage(Optional AttachmentPath)
On Error GoTo ErrorMsgs

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. Substitute
' your names here.
Set objOutlookRecip = .Recipients.Add("Nancy Davolio")
objOutlookRecip.Type = olTo

' Add the CC recipient(s) to the message.
Set objOutlookRecip = .Recipients.Add("Andrew Fuller")
objOutlookRecip.Type = olCC

' Set the Subject, Body, and Importance of the message.
.Subject = "This is an Automation test with Microsoft Outlook"
.Body = "Last test." & vbCrLf & vbCrLf
.Importance = olImportanceHigh 'High importance
.ReadReceiptRequested = True '<-------------

' 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
If Not objOutlookRecip.Resolve Then
objOutlookMsg.Display
End If

Next
.Send
End With
Set objOutlookMsg = Nothing
Set objOutlook = Nothing
Set objOutlookRecip = Nothing
Set objOutlookAttach = Nothing
ErrorMsgs:
If Err.Number = "287" Then
MsgBox "You clicked No to the Outlook security warning. " & _
"Rerun the procedure and click Yes to access e-mail" & _
"addresses to send your message. For more information, " & _
"see the document at http://www.microsoft.com/office" & _
"/previous/outlook/downloads/security.asp."
Else
MsgBox Err.Number, Err.Description
End If
End Sub


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
S

Stockwell43

Hi Tom, thank you for replying.

Is it possible to just cut and paste the Read Receipt line and place it in
my code that I am already using for my email? If so, where should it go
within the code or does it even matter?

Thanks!!!
 
T

Tom Wickerath

Is it possible to just cut and paste the Read Receipt line and place it in
my code that I am already using for my email? If so, where should it go
within the code or does it even matter?

How could I possibly answer this question....after all, I haven't seen your
code?

Are you using Outlook and not Outlook Express or some other e-mail client,
such as Lotus Notes?


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
S

Stockwell43

Here you go, it's just a quick macro.

Private Sub Command15_Click()
On Error GoTo Command15_Click_Err

DoCmd.SendObject acReport, "rptProduction", "RichTextFormat(*.rtf)",
"[email protected]", "", "", "Production Report", "", True, ""


Command15_Click_Exit:
Exit Sub

Command15_Click_Err:
MsgBox Error$
Resume Command15_Click_Exit

End Sub
 
T

Tom Wickerath

Since you are using SendObject, the answer to your earlier question is no.
You will need to use code similar to what I showed you from the MSDN article.
As an alternative, I have late bound code for automating Outlook (no checked
reference required to the Outlook Object library with late bound code)
available in a Word document that I call Access Links. You are welcome to
download a zipped copy from my web site
(http://www.accessmvp.com/TWickerath/). My procedure does not currently
include a provision for a read receipt, but it shouldn't be too hard to
figure out how to add it, after looking at the previous code I gave you from
the MSDN article.

Search the Word document (<Ctrl><F>) for the word: "Outlook" (without the
quotes). I think the procedure is on page 17 or so...


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
S

Stockwell43

Sounds good, I'll give it a shot. Thanks Tom, I appreciate you sticking with
me on this and thanks for your help!
 
Top