PC Review


Reply
Thread Tools Rate Thread

Email Sent Confirmation

 
 
=?Utf-8?B?REVJ?=
Guest
Posts: n/a
 
      14th Nov 2005
I am using the following code to automate an email message from Access. I
would like to automatically update fields on a form in Access witha time
stamp to confirm when the message was sent. I would also like the email
message to display before it is sent.

I can easily make the form in Access update automatically, however, it will
be possible for the user to cancel the message, in which case the form should
not be stamped because no message ws sent. Unfortunately, though, when I
create the email message in the code, the code keeps running. I am basically
looking for the best place, or best way to evaluate that a message was sent.
So that if the user cancels the message, then the form does not update.

Is there any way to halt execution? Or pause before the user either sends or
aborts the message?

Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg

.To = em
.Subject = stext
.Body = mtext
.Display

End With
 
Reply With Quote
 
 
 
 
=?Utf-8?B?RXJpYyBMZWdhdWx0IFtNVlAgLSBPdXRsb29rXQ==
Guest
Posts: n/a
 
      14th Nov 2005
You need to declare a MailItem variable using the WithEvents statement to
hook into user or application driven events, such as sending the e-mail.

Dim objOutlook As Outlook.Application
Dim WithEvents objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient

Set objOutlook = CreateObject("Outlook.Application")
Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg

.To = em
.Subject = stext
.Body = mtext
.Display
End With

Then you can use this event to determine if the e-mail was sent or not:

Private Sub objOutlookMsg_Send(Cancel As Boolean)
'Your code here
End Sub

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"DEI" wrote:

> I am using the following code to automate an email message from Access. I
> would like to automatically update fields on a form in Access witha time
> stamp to confirm when the message was sent. I would also like the email
> message to display before it is sent.
>
> I can easily make the form in Access update automatically, however, it will
> be possible for the user to cancel the message, in which case the form should
> not be stamped because no message ws sent. Unfortunately, though, when I
> create the email message in the code, the code keeps running. I am basically
> looking for the best place, or best way to evaluate that a message was sent.
> So that if the user cancels the message, then the form does not update.
>
> Is there any way to halt execution? Or pause before the user either sends or
> aborts the message?
>
> Dim objOutlook As Outlook.Application
> Dim objOutlookMsg As Outlook.MailItem
> Dim objOutlookRecip As Outlook.Recipient
>
> Set objOutlook = CreateObject("Outlook.Application")
> Set objOutlookMsg = objOutlook.CreateItem(olMailItem)
>
> With objOutlookMsg
>
> .To = em
> .Subject = stext
> .Body = mtext
> .Display
>
> End With

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to send an automatic confirmation of email receipt of email Carolyn Microsoft Outlook Discussion 1 2nd Nov 2009 04:35 PM
Confirmation of Email Sent DEI Microsoft Access VBA Modules 3 5th Nov 2008 01:26 PM
Confirmation Email =?Utf-8?B?R2FyeSBEb2xsaXZlcg==?= Microsoft Access Form Coding 1 7th Nov 2007 03:17 AM
Can Frontpage email a confirmation from an email field? =?Utf-8?B?TWF1cmljZQ==?= Microsoft Frontpage 4 8th May 2006 10:10 AM
create confirmation email in vba when email received Microsoft Outlook VBA Programming 1 23rd Jan 2004 04:07 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:01 AM.