![]() |
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. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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...? |
Ads |
#2
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
Hi. If you add "+ vbSystemModal" to the MsgBox statement, it works ok with MS
Word as the editor. The email closes and then you can see the message box which is fine (before, the email froze after sending). "Robin" wrote: 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 |
#8
|
|||
|
|||
![]()
Oops. it seems freezing still happens, depending on what is open at the time.
So I am trying to get the other API hack that you suggested working. Just to check, I currently use a standard Msgbox statement, but in order to get its hwnd, do I need to create a new form instead (that looks exactly like a msgbox) and then use the statement SetWindowPos(Form1.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE) or is there a way of getting the hwnd of a standard msgbox? Thanks a lot. "Robin" wrote: Hi. If you add "+ vbSystemModal" to the MsgBox statement, it works ok with MS Word as the editor. The email closes and then you can see the message box which is fine (before, the email froze after sending). "Robin" wrote: 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 |
#9
|
|||
|
|||
![]()
I personally don't like to try to control a MsgBox that way. I prefer to
create an equivalent form and open it non-modally. I then set it to the top and make it modal in the Activate event of the form. That will work even with WordMail if you get the right window handle. -- 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 ... Oops. it seems freezing still happens, depending on what is open at the time. So I am trying to get the other API hack that you suggested working. Just to check, I currently use a standard Msgbox statement, but in order to get its hwnd, do I need to create a new form instead (that looks exactly like a msgbox) and then use the statement SetWindowPos(Form1.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE) or is there a way of getting the hwnd of a standard msgbox? Thanks a lot. |
#10
|
|||
|
|||
![]()
Hi Ken
I have come back this and am still struggling. I am struggling to get the hWnd for the UserForm. (error: compile error, method or data member not found). I am struggling to get anything on the internet. The code so far: Public HWND_TOPMOST As Integer Public SWP_NOSIZE Public SWP_NOMOVE Public SWP_NOACTIVATE Private Declare Sub setWindowPos Lib "User" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) Dim objFolder As Outlook.MAPIFolder Dim oSent As Outlook.MAPIFolder Dim objNS As Outlook.NameSpace WND_TOPMOST = -1 SWP_NOSIZE = &H1 SWP_NOMOVE = &H2 SWP_NOACTIVATE = &H10 If Item.Class = olMail Then UserForm1.Show Call setWindowPos(UserForm1.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE Or SWP_NOACTIVATE) If answer = "No" Then 'No from UserForm1, I do not want to save the email On Error Resume Next Set objNS = Application.GetNamespace("MAPI") Set oSent = objNS.GetDefaultFolder(olFolderSentMail) Set objFolder = oSent.Folders("Temp Sent") 'Assume this is a mail folder If objFolder Is Nothing Then MsgBox "This folder doesn't exist!", vbOKOnly + vbExclamation, "INVALID FOLDER" End If If Application.ActiveInspector Is Nothing Then 'Require that this procedure be called for an open item Exit Sub End If If Application.ActiveInspector.CurrentItem.Class olMail Then Exit Sub End If Set Item.SaveSentMessageFolder = objFolder Set objFolder = Nothing Set oSent = Nothing Set objNS = Nothing End If End If End Sub Your help would be greatly appreciated... "Ken Slovak - [MVP - Outlook]" wrote: I personally don't like to try to control a MsgBox that way. I prefer to create an equivalent form and open it non-modally. I then set it to the top and make it modal in the Activate event of the form. That will work even with WordMail if you get the right window handle. -- 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 ... Oops. it seems freezing still happens, depending on what is open at the time. So I am trying to get the other API hack that you suggested working. Just to check, I currently use a standard Msgbox statement, but in order to get its hwnd, do I need to create a new form instead (that looks exactly like a msgbox) and then use the statement SetWindowPos(Form1.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE) or is there a way of getting the hwnd of a standard msgbox? Thanks a lot. |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Custom action | Ian | Outlook - General Queries | 9 | April 23rd 07 10:05 PM |
Save while sending email in Outlook | Marc C | Outlook and VBA | 1 | December 19th 06 07:55 PM |
Custom Action DLL with VB? | Menachem Bazian | Outlook - General Queries | 4 | August 18th 06 02:58 AM |
Outlook 2003 Custom Action on Outgoing Email Rules | Pankaj | Outlook and VBA | 1 | June 25th 06 10:35 AM |
custom action | adubb | Outlook - Using Forms | 1 | March 30th 06 09:17 PM |