ItemSend does not fire in Outlook 2003

S

S.T.Arun

The story begins like this: Many a times I forget the attachments in
the mail across. So I wanted to write a small trigger on the outlook
client which checks if the sent message contained words like 'attach'
and check if there is any attachment in the mail or not, before
sending the mail. If the attachment is missing exception is raised to
the user. The code for it is as below:
---------------------------------------------------------------------
Public Sub Application_ItemSend(ByVal Item As Object, Cancel As
Boolean)
Dim prompt As String
Dim checkBodyAttachStr, checkSubAttachStr As Integer
Dim checkAttachmentCnt As Integer
Dim ForbiddenString(10) As String
Dim I, MaxWords As Integer
Dim AttachWordPresent As Boolean

MaxWords = 3
ForbiddenString(1) = "Attach"
ForbiddenString(2) = "PFA"
ForbiddenString(3) = "attched"
For I = 1 To MaxWords
checkBodyAttachStr = InStrRev(Item.Body, ForbiddenString(I), ,
vbTextCompare)
checkSubAttachStr = InStrRev(Item.Subject, ForbiddenString(I),
, vbTextCompare)
If ((checkBodyAttachStr <> 0 Or checkBodyAttach <> Null) Or
(checkSubAttachStr <> 0 Or checkSubAttach <> Null)) Then
AttachWordPresent = True
Exit For
End If
Next I
checkAttachmentCnt = Item.Attachments.Count
If ((AttachWordPresent = True) And (checkAttachmentCnt <= 0)) Then
prompt = "Oh Dear, You forgot the Attachment! Continue
Sending?"
If MsgBox(prompt, vbYesNo + vbQuestion, "Sample") = vbNo Then
Cancel = True
Else
Cancel = False
End If
End If
End Sub
---------------------------------------------------------------------
When the mail account is configured as 'Pop3' or 'IMAP' this code in
'ThisOutlookSession' fires and I get proper response (it works the way
it should). But when the mail account is configured as 'Microsoft
Exchange Server account (MAPI)' and if the mails are seen on the
exchange server, this code does not work.

Questions:
1. Is there any other (better) way of doing a similar check of
attachments in sent mails?
2. What is the difference in VBA event when the mail account is
configured as 'POP3/IMAP' and 'MS Exchange Server account'?

Looking forward to hearing from you

Regards
Arun
 
G

Guest

What exactly doesn't work with your code when the e-mail is sent via
Exchange? Try setting some breakpoints to see if the event is even firing or
what sections aren't working as you expect.

There should be no difference in how Item_Send functions based on the chosen
account. Other than that, your code looks fine.
 
N

news.microsoft.com

I recently had the same problem with ItemSend not firing.

It was due to the security level blocking macros.

In Outlook try : Tools -> Macro -> Security and set security level to low.
Then check if Application_ItemSend Fires.

Shiraz
 
S

S.T.Arun

Hi

I tried setting the security level to low. But still the event does not fire!

Arun
 
S

S.T.Arun

The event Application_ItemSend itself doesn't fire while sending the
mail through Exchange. Even if I set the security to low, still the
event doesn't occur!!!

Regards
Arun
 
A

arun.srinivas

Got it solved! Looks like we have to write a dummy macro and the event
starts firing!

Thank you all for your inputs.

Rega
rds
Arun
 
Joined
Oct 31, 2014
Messages
1
Reaction score
0
Arun,

Can you explain what you mean by a 'dummy' macro that gets the Application_ItemSend event to start firing.

I'm having this same problem and haven't found a solution yet.

Thanks

Brendon
 

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