A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Outlook within Excel, get return code to know if user pressed SEND



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 19th 07, 06:38 PM posted to microsoft.public.outlook.program_vba
gary
external usenet poster
 
Posts: 110
Default Outlook within Excel, get return code to know if user pressed SEND

Question: Using the Outlook object model within Excel, can I get the return
code to know if the Sender pressed the SEND button?


I use the following code within Excel to send Outlook email. I would like
to know how to determine if the user actually pressed the SEND button within
Outlook. I will use the return code to log (or not) the activity. The
sender must have the option to send or not. I am using this form vs the send
mail dialog because this form allows the customization of the EmailBody based
on information contained on the row associated with the recipient.

I have checked both the Excel and Outlook communities and haven't found the
answer. In addition, I have done a web search using "outlook object model
email send" as the criteria and have found some very interesting stuff, but
have not been able to get an answer (that I understand). Any help would be
appreciated.

Thanks, Regards,

Gary

'
'Code segment – send an email with a custom letter based on recipient
information 'contained in the row
'
With OutMail
.to = EmailTo
.CC = ""
.BCC = ""
.Subject = EmailSubject
.Body = EmailBody
.Display
End With
'
'Now check the return code. Did the sender press the send button, or did
the user 'Close/Exit?
'
If sent Then Log_it

'done

  #2  
Old July 19th 07, 09:42 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Outlook within Excel, get return code to know if user pressed SEND

Take a look at my blog to see an example of how to wire up Outlook to handle
e-mail events:

Eric Legault My Eggo : Getting a Handle on Your E-mails with VBA:
http://blogs.officezealot.com/legault/pages/20086.aspx

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"gary" wrote:

Question: Using the Outlook object model within Excel, can I get the return
code to know if the Sender pressed the SEND button?


I use the following code within Excel to send Outlook email. I would like
to know how to determine if the user actually pressed the SEND button within
Outlook. I will use the return code to log (or not) the activity. The
sender must have the option to send or not. I am using this form vs the send
mail dialog because this form allows the customization of the EmailBody based
on information contained on the row associated with the recipient.

I have checked both the Excel and Outlook communities and haven't found the
answer. In addition, I have done a web search using "outlook object model
email send" as the criteria and have found some very interesting stuff, but
have not been able to get an answer (that I understand). Any help would be
appreciated.

Thanks, Regards,

Gary

'
'Code segment – send an email with a custom letter based on recipient
information 'contained in the row
'
With OutMail
.to = EmailTo
.CC = ""
.BCC = ""
.Subject = EmailSubject
.Body = EmailBody
.Display
End With
'
'Now check the return code. Did the sender press the send button, or did
the user 'Close/Exit?
'
If sent Then Log_it

'done

  #3  
Old July 20th 07, 06:56 PM posted to microsoft.public.outlook.program_vba
gary
external usenet poster
 
Posts: 110
Default Outlook within Excel, get return code to know if user pressed

Eric:
Thank you very much for the blog reference. There is a wealth of
information contained in it -- and I found the (several) specific discussions
about how to detect if the sender actually sent the message or closed and did
not send. I have spent the last several hours trying to make it work, but
alas, have come up empty. Your coding and discussions are clear -- the
problem is with me and how to implement the code.

I work in an environment that restricts what I can do on a system. I can do
the following:

Write excel macros that are triggered by the user pressing a button. A
button is assigned to a macro. The macro resides in a module. The module is
created by an "INSERT MODULE" menu action. These are not CLASS MODULEs.

So, I'm struggling with where to put your example code, because it is not
allowed in the everyday garden variety Module. I can put it in a CLASS
MODULE, but then I can't figure out how to reference it from a button on the
spreadsheet.

I have been using email code from Excel for quite some time, and it works
wonderfully (and, by the way, I dont seem to have the security problem that a
lot of people reference!!!) Your help is greatly appeciated, and a little
bit more to get me over the hurdle would also be greatly appreciated -- and a
great learning experience for me.

Thanks, Regards,
Gary

P.S. I believe the final answer warrants publishing to both the Excel and
Outlok communities.

"Eric Legault [MVP - Outlook]" wrote:

Take a look at my blog to see an example of how to wire up Outlook to handle
e-mail events:

Eric Legault My Eggo : Getting a Handle on Your E-mails with VBA:
http://blogs.officezealot.com/legault/pages/20086.aspx

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"gary" wrote:

Question: Using the Outlook object model within Excel, can I get the return
code to know if the Sender pressed the SEND button?


I use the following code within Excel to send Outlook email. I would like
to know how to determine if the user actually pressed the SEND button within
Outlook. I will use the return code to log (or not) the activity. The
sender must have the option to send or not. I am using this form vs the send
mail dialog because this form allows the customization of the EmailBody based
on information contained on the row associated with the recipient.

I have checked both the Excel and Outlook communities and haven't found the
answer. In addition, I have done a web search using "outlook object model
email send" as the criteria and have found some very interesting stuff, but
have not been able to get an answer (that I understand). Any help would be
appreciated.

Thanks, Regards,

Gary

'
'Code segment – send an email with a custom letter based on recipient
information 'contained in the row
'
With OutMail
.to = EmailTo
.CC = ""
.BCC = ""
.Subject = EmailSubject
.Body = EmailBody
.Display
End With
'
'Now check the return code. Did the sender press the send button, or did
the user 'Close/Exit?
'
If sent Then Log_it

'done

  #4  
Old July 20th 07, 07:56 PM posted to microsoft.public.outlook.program_vba
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Outlook within Excel, get return code to know if user pressed

Okay, it's a little different if you are hosting this code in Excel. You
need to map that custom button to a procedure of your choice in whatever
module that procedure is living in. Then instantiate the trapper class
(you'll still need to create that Class Module with all the code) from that
proc. E.g.:

[code below in 'Module1']

Option Explicit

Public myMailItemTrapper As clsMailItemTrapper

Sub MyCustomButtonWillRunThisProcedure()

Set myMailItemTrapper = New clsMailItemTrapper

End Sub

To be clean, you should call Set myMailItemTrapper = Nothing from the
appropriate Deactivate event when the app or workbook is closed.

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"gary" wrote:

Eric:
Thank you very much for the blog reference. There is a wealth of
information contained in it -- and I found the (several) specific discussions
about how to detect if the sender actually sent the message or closed and did
not send. I have spent the last several hours trying to make it work, but
alas, have come up empty. Your coding and discussions are clear -- the
problem is with me and how to implement the code.

I work in an environment that restricts what I can do on a system. I can do
the following:

Write excel macros that are triggered by the user pressing a button. A
button is assigned to a macro. The macro resides in a module. The module is
created by an "INSERT MODULE" menu action. These are not CLASS MODULEs.

So, I'm struggling with where to put your example code, because it is not
allowed in the everyday garden variety Module. I can put it in a CLASS
MODULE, but then I can't figure out how to reference it from a button on the
spreadsheet.

I have been using email code from Excel for quite some time, and it works
wonderfully (and, by the way, I dont seem to have the security problem that a
lot of people reference!!!) Your help is greatly appeciated, and a little
bit more to get me over the hurdle would also be greatly appreciated -- and a
great learning experience for me.

Thanks, Regards,
Gary

P.S. I believe the final answer warrants publishing to both the Excel and
Outlok communities.

"Eric Legault [MVP - Outlook]" wrote:

Take a look at my blog to see an example of how to wire up Outlook to handle
e-mail events:

Eric Legault My Eggo : Getting a Handle on Your E-mails with VBA:
http://blogs.officezealot.com/legault/pages/20086.aspx

--
Eric Legault - Outlook MVP, MCDBA, MCTS (SharePoint programming, etc.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"gary" wrote:

Question: Using the Outlook object model within Excel, can I get the return
code to know if the Sender pressed the SEND button?


I use the following code within Excel to send Outlook email. I would like
to know how to determine if the user actually pressed the SEND button within
Outlook. I will use the return code to log (or not) the activity. The
sender must have the option to send or not. I am using this form vs the send
mail dialog because this form allows the customization of the EmailBody based
on information contained on the row associated with the recipient.

I have checked both the Excel and Outlook communities and haven't found the
answer. In addition, I have done a web search using "outlook object model
email send" as the criteria and have found some very interesting stuff, but
have not been able to get an answer (that I understand). Any help would be
appreciated.

Thanks, Regards,

Gary

'
'Code segment – send an email with a custom letter based on recipient
information 'contained in the row
'
With OutMail
.to = EmailTo
.CC = ""
.BCC = ""
.Subject = EmailSubject
.Body = EmailBody
.Display
End With
'
'Now check the return code. Did the sender press the send button, or did
the user 'Close/Exit?
'
If sent Then Log_it

'done

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ask question when Send is pressed John Outlook - Using Forms 1 June 22nd 07 12:49 PM
My Excel 2007 VBA code causes intermittant NumLock switching TomThumb Outlook and VBA 0 June 8th 07 01:02 PM
Intermittant NumLock changes in my Excel 2007 VBA macro code TomThumb Outlook and VBA 2 June 8th 07 12:57 PM
Excel import won't recognize zip code fields, others are fine emspooner Outlook - Using Contacts 2 March 21st 06 06:39 PM
Import Outlook Contact Postal Code from Excel Vaughn Outlook - Using Contacts 1 January 28th 06 12:14 PM


All times are GMT +1. The time now is 10:42 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.