| Code level: beginner Code area: Basic Outlook Printer Friendly Version | ||
| Title: Don't send message if attachment is missing | ||
| Description: In response to a post: "I want to be able to make outlook scan the text of outgoing e-mails and if it contains "attach" or "attached" or "enclosed" to warn me before it allows me to send an e-mail without an attachment, it will stop me having to send loads of "whoops" messages around the office." The code needs to go in the ThisOutlookSession module in Outlook VBA; make sure macro security is not set to High. | ||
| Date: 25-Jun-2003 07:16 | ||
| Code level: beginner | ||
| Code area: Basic Outlook | ||
| Posted by: Sue Mosher | ||
| Body: |
||
| All 54comments |
| Page [ 1 2 3 4 5 6 Next >> ] | ||
|
|
Sue Mosher
30-Jun-2003 09:05
Note the use of Cancel=True to cancel the sending of the item. |
|
|
|
Sue Mosher
30-Jun-2003 09:44
Here's another variation to prevent you from sending a message with a blank subject: Private Sub Application_ItemSend(ByVal Item as Object, Cancel as Boolean) If Item.Subject = "" Then MsgBox "You forgot the subject." Cancel = True End If End Sub |
|
|
|
steve lester
18-Jul-2003 10:41
This subroutine doesn't let you send if you don't want an attachment. Better to use this. Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean) ' If InStr(1, Item.Body, "attach", vbTextCompare) > 0 Then If Item.Attachments.Count = 0 Then ans = MsgBox("There's no attachment, send anyway?", vbYesNo) If ans = vbNo Then Cancel = True End If End If End Sub |
|
|
|
Michael
20-Apr-2004 14:27
OK so I'm trying to move the blank subject check into a COM object for use in deploying across a bunch of machine, and I can't get the triggering to happen correctly. I've tested the setup with some onConnection MsgBox's and the dll works, just not the on send trigger. Any help? |
|
|
|
Sue Mosher
21-Apr-2004 13:24
Michael, in what module did you put your procedure and how did you instantiate the Application object that you're using for it? Get the Items Command Bar sample from http://www.microeye.com for best practices. |
|
|
|
Yannick Lefebvre
19-May-2004 10:53
I have been looking for something like this for quite a while. I wonder why no one has created a freeware plugin to Outlook with this code. I am thinking about creating a plugin myself for my own use and to distribute in my company. I have downloaded the Command Bar sample that you mentioned but am a bit lost where to start to insert this code and what code should be removed. For one, this example does not have the "ThisOutlookSession module" that you are referring to in your first post. |
|
|
|
Yannick Lefebvre
19-May-2004 11:50
I have found what you meant by ThisOutlookSession module and have gotten the code sample to work. Now I will look to create a plugin out of this. |
|
|
|
Yannick Lefebvre
19-May-2004 12:52
Sorry for this double-post. I have found an article on Microsoft's web site explaining how to create a plug-in for Outlook and was able to easily create an Add-In for this. Now, the problem I have encountered is on copied of Outlook where Word has been selected as the mail editor. When you try to send the e-mail, it goes through the Add-In code, and Outlook displays the MsgBox. However, since the MsgBox's parent is Outlook and not Word, the dialog appears behind the e-mail window that the user is working in. Any ideas on ways to correct this? Yannick |
|
|
|
puay yeong
14-Jul-2004 04:06
Hi i am wondering how to get this to work if i have selected wordmail as my mail editor as when wordmail is selected it will block the view of any msg box and the standard bars are different as well. |
|
|
|
Sue Mosher
20-Jul-2004 10:23
I've never had any problem using ItemSend with WordMail as the editor. |
|
| Page [ 1 2 3 4 5 6 Next >> ] | ||
| Post your comment name email |
