Attach a file, or not

  • Thread starter Thread starter Jeff Bienstadt
  • Start date Start date
J

Jeff Bienstadt

Is there a way to prevent or cancel an attachment?

When an Outlook user attempts to attach a file to a mail item, I would like
to be able to programmatically decide whether the attachment meets certain
criteria and either allow or disallow the attachment process to continue.

I've seen code which puts up a warning message box when the AttachmentAdd
event fires, but is there a way to prevent the attachment entirely? Perhaps
an event that fires *before* the attachment is added?

If all else fails, is there a way to hook into the attachment selection
dialog box? I know that Outlook puts up its own dialog, as opposed to
calling the Win32 GetOpenFileName API function. Is this dialog something
that I can detect and intercept using an addin?

Any help or suggestions would be greatly appreciated.

Thanks

---jkb
 
No, there is no BeforeAttachmentAdd event, nor does Outlook provide a hook
for its dialog. An alternative approach might be to evaluate all attachments
when the user sends the message.
 
Thanks, Sue, for your prompt reply and your alternative suggestion.
Unfortunately, it's not what my customer wants.

Is it safe to delete the attachment while in the AttachmentAdd handler? Are
there any hoops I'd need to jump through to make that work?

Thanks again,

---jkb
 
Have you considered trapping the send event so that you can check if the
attachment(s) meet your predefined criteria.

If they do not then remove before sending and if appropriate display a
dialogue to the user.

--
Regards
Graeme
=====================================
Websetters - home of the WS:Outlook AddIn
the only limits are those of vision...
www.websetters.co.uk
=====================================
 
Sorry, just received the response from Sue... apologises for duplicating
response ...

Regards
Graeme
=====================================
Websetters - home of the WS:Outlook AddIn
the only limits are those of vision...
www.websetters.co.uk
=====================================
 
I don't know. Why don't you try it?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top