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

custom action: save or delete email after sending



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 2nd 07, 09:38 AM posted to microsoft.public.outlook.program_vba
robin
external usenet poster
 
Posts: 53
Default custom action: save or delete email after sending

Hi. I would like to create a custom action that pops up a message box on
sending an email. This will ask me whether I would like this saved to my sent
items folder or not. This will make organising my sent items much easier
later on. Any ideas...?
  #2  
Old May 2nd 07, 01:50 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default custom action: save or delete email after sending

A better solution would be to use an Application_ItemSend event handler that
will fire every time an item is sent and show a message box asking whether
to save to Sent Items and if the answer is no to set the DeleteAfterSubmit
Boolean property to True.

If macros are enabled and this code is in ThisOutlookSession you will have
what you want, but I'd think it would get annoying after a while to be
prompted after sending every email.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim answer As Long

If Item.Class = olMail Then
answer = MsgBox("Do you want to save this email: " & _
Item.Subject & " to Sent Items?", vbYesNo)

If answer = vbNo Then
Item.DeleteAfterSubmit = True
End If
End If
End Sub


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Robin" wrote in message
...
Hi. I would like to create a custom action that pops up a message box on
sending an email. This will ask me whether I would like this saved to my
sent
items folder or not. This will make organising my sent items much easier
later on. Any ideas...?


  #3  
Old May 2nd 07, 02:21 PM posted to microsoft.public.outlook.program_vba
robin
external usenet poster
 
Posts: 53
Default custom action: save or delete email after sending

That's perfect thanks. I know this might result in a small amount of pain,
but I am sure it will be worth it when it comes to organising my sent emails.
A bells and whistles version of this would be a form which pops up after
sending an email which shows my outlook folders and asks me to which folder I
want file the sent email with a "DELETE EMAIL" as the top option. Painful I
know but I will have to do this some time anyway...
Cheers.

"Ken Slovak - [MVP - Outlook]" wrote:

A better solution would be to use an Application_ItemSend event handler that
will fire every time an item is sent and show a message box asking whether
to save to Sent Items and if the answer is no to set the DeleteAfterSubmit
Boolean property to True.

If macros are enabled and this code is in ThisOutlookSession you will have
what you want, but I'd think it would get annoying after a while to be
prompted after sending every email.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim answer As Long

If Item.Class = olMail Then
answer = MsgBox("Do you want to save this email: " & _
Item.Subject & " to Sent Items?", vbYesNo)

If answer = vbNo Then
Item.DeleteAfterSubmit = True
End If
End If
End Sub


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Robin" wrote in message
...
Hi. I would like to create a custom action that pops up a message box on
sending an email. This will ask me whether I would like this saved to my
sent
items folder or not. This will make organising my sent items much easier
later on. Any ideas...?



  #4  
Old May 3rd 07, 10:30 AM posted to microsoft.public.outlook.program_vba
robin
external usenet poster
 
Posts: 53
Default custom action: save or delete email after sending

Sorry, one little snag. When I click on send, the PC freezes. I have to click
on the Microsoft Outlook tab on the taskbar which brings the message box to
the front and then select YES/NO. Any ideas on how to solve this (minimise
current window?)
Thanks again

"Robin" wrote:

That's perfect thanks. I know this might result in a small amount of pain,
but I am sure it will be worth it when it comes to organising my sent emails.
A bells and whistles version of this would be a form which pops up after
sending an email which shows my outlook folders and asks me to which folder I
want file the sent email with a "DELETE EMAIL" as the top option. Painful I
know but I will have to do this some time anyway...
Cheers.

"Ken Slovak - [MVP - Outlook]" wrote:

A better solution would be to use an Application_ItemSend event handler that
will fire every time an item is sent and show a message box asking whether
to save to Sent Items and if the answer is no to set the DeleteAfterSubmit
Boolean property to True.

If macros are enabled and this code is in ThisOutlookSession you will have
what you want, but I'd think it would get annoying after a while to be
prompted after sending every email.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim answer As Long

If Item.Class = olMail Then
answer = MsgBox("Do you want to save this email: " & _
Item.Subject & " to Sent Items?", vbYesNo)

If answer = vbNo Then
Item.DeleteAfterSubmit = True
End If
End If
End Sub


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Robin" wrote in message
...
Hi. I would like to create a custom action that pops up a message box on
sending an email. This will ask me whether I would like this saved to my
sent
items folder or not. This will make organising my sent items much easier
later on. Any ideas...?



  #5  
Old May 3rd 07, 01:58 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default custom action: save or delete email after sending

Using WordMail, correct? That's a problem. Word is being subclassed by
Outlook and WordMail items are a weird mix of in and out of process threads.
The bottom line is that the parent window of the message box is most likely
the Outlook Explorer window and not the WordMail window.

The best way to fix that is to display a dialog box non-modally, get its
hWnd and use that in a call to SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOSIZE + SWP_NOMOVE). After that call to set your dialog on top of all
other windows you can then make the dialog modal.

An easier alternative that doesn't involve hacks with Win32 API calls would
be to not use WordMail.

If you decide to use the hack approach all those consts and the declaration
for SetWindowPos are in the MSDN library.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Robin" wrote in message
...
Sorry, one little snag. When I click on send, the PC freezes. I have to
click
on the Microsoft Outlook tab on the taskbar which brings the message box
to
the front and then select YES/NO. Any ideas on how to solve this (minimise
current window?)
Thanks again


  #6  
Old May 3rd 07, 02:11 PM posted to microsoft.public.outlook.program_vba
robin
external usenet poster
 
Posts: 53
Default custom action: save or delete email after sending

Thanks Ken. It works fine wih the non-Wordmail option. Much appreciated.

"Ken Slovak - [MVP - Outlook]" wrote:

Using WordMail, correct? That's a problem. Word is being subclassed by
Outlook and WordMail items are a weird mix of in and out of process threads.
The bottom line is that the parent window of the message box is most likely
the Outlook Explorer window and not the WordMail window.

The best way to fix that is to display a dialog box non-modally, get its
hWnd and use that in a call to SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0,
SWP_NOSIZE + SWP_NOMOVE). After that call to set your dialog on top of all
other windows you can then make the dialog modal.

An easier alternative that doesn't involve hacks with Win32 API calls would
be to not use WordMail.

If you decide to use the hack approach all those consts and the declaration
for SetWindowPos are in the MSDN library.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Robin" wrote in message
...
Sorry, one little snag. When I click on send, the PC freezes. I have to
click
on the Microsoft Outlook tab on the taskbar which brings the message box
to
the front and then select YES/NO. Any ideas on how to solve this (minimise
current window?)
Thanks again



  #7  
Old May 20th 08, 05:28 AM posted to microsoft.public.outlook.program_vba
M.D'Souza
external usenet poster
 
Posts: 1
Default custom action: save or delete email after sending

Hi I'm trying to something similar only instead of saving the reply I would
like it to delete the original message from the inbox. Is this doable?

"Robin" wrote:

Hi. I would like to create a custom action that pops up a message box on
sending an email. This will ask me whether I would like this saved to my sent
items folder or not. This will make organising my sent items much easier
later on. Any ideas...?

  #8  
Old May 21st 08, 04:27 PM posted to microsoft.public.outlook.program_vba
Guest
 
Posts: n/a
Default custom action: save or delete email after sending

Yes, that is quite possible. You can trap the MailItem's Send event and
throw your dialog there. The ActiveExplorer.Selection object should contain
a reference to the message that is being replied to, or one of the messages
in the Application.Inspectors collection. In either situation, you can loop
through the collection and compare the Subject property with the current
reply message.

--
Eric Legault [MVP - Outlook]
MCDBA, MCTS (Messaging & Collaboration, SharePoint Infrastructure, MOSS 2007
& WSS 3.0 Application Development)
Collaborative Innovations
- Try Picture Attachments Wizard For Microsoft Outlook -
Web: http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault


"M.D'Souza" wrote in message
...
Hi I'm trying to something similar only instead of saving the reply I
would
like it to delete the original message from the inbox. Is this doable?

"Robin" wrote:

Hi. I would like to create a custom action that pops up a message box on
sending an email. This will ask me whether I would like this saved to my
sent
items folder or not. This will make organising my sent items much easier
later on. Any ideas...?


 




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
Custom action Ian Outlook - General Queries 9 April 23rd 07 09:05 PM
Save while sending email in Outlook Marc C Outlook and VBA 1 December 19th 06 06:55 PM
Custom Action DLL with VB? Menachem Bazian Outlook - General Queries 4 August 18th 06 01:58 AM
Outlook 2003 Custom Action on Outgoing Email Rules Pankaj Outlook and VBA 1 June 25th 06 09:35 AM
custom action adubb Outlook - Using Forms 1 March 30th 06 08:17 PM


All times are GMT +1. The time now is 03:37 PM.


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.