Stopping email from being sent with blank subject

G

Guest

I have this Code that does not seem to work in OL2003 when placeing in
ThisOutlookSession

Private Sub Application_ItemForgot(ByVal Item As Object, Cancel As Boolean)

If Item.Subject = "" Then
MsgBox "Forgot Subject"
Cancel = True

End If


End Sub

This a code modified from sue.

I use word as my editor if that matters


End Sub
 
M

Michael Bauer [MVP - Outlook]

Funny modification, Outlook doesn't know an 'ItemForgot' event :)

The event is called ItemSend, that name cannot be changed. If you want to
have a procedure with that name (which is really useful if your code gets
more and more) then do it like this:

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

ItemForgot Item, Cancel

End Sub

Private Sub ItemForgot(ByVal Item As Object, Cancel As Boolean)

If Item.Subject = "" Then
MsgBox "Forgot Subject"
Cancel = True
End If

End Sub

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
Quick-Cats - Categorize Outlook data:
http://www.vboffice.net/product.html?id=2006063&cmd=detail&lang=en&pub=6

Am Fri, 20 Apr 2007 16:12:01 -0700 schrieb sfleck:
 
M

Michael Bednarek

I have this Code that does not seem to work in OL2003 when placeing in
ThisOutlookSession

Private Sub Application_ItemForgot(ByVal Item As Object, Cancel As Boolean)

If Item.Subject = "" Then
MsgBox "Forgot Subject"
Cancel = True

End If


End Sub

This a code modified from sue.

I use word as my editor if that matters

As Michael Bauer already pointed out, there's no such event as _ItemForgot,
and consequently that procedure will never be called.

Here's my variation that theme (3 lines):

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
If Item.Class = olMail Then If Item.Subject = "" Then If MsgBox("Empty ""Subject:"" line. Send item?", vbYesNo + vbQuestion, "MB SendMail") <> vbYes Then Cancel = True
End Sub
 
G

Guest

So if I have another Private Sub Application_ItemSend(ByVal Item As Object,
Cancel As Boolean)

then I addit into this way?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top