Solved

Need a Module to automatically detach all attachments to a named drive

Posted on 2002-04-24
5
438 Views
Last Modified: 2006-11-17
In Outlook I have an email accountwhere i receive file attachments from various people in the organization.  What i would like to do is to is for ANY incoming email to my folder have a procedure that will run and Detach ALL attachments within the email to S:\AAGIS\Files

What code would i need for this procedure and where would I put it in outlook so that it could run evry time an email came in?
0
Comment
Question by:quizzer
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 9

Accepted Solution

by:
rjcpjc earned 250 total points
ID: 6966065
In Outlook 2000 or higher, you would put the code in VBA from within Outlook (or in a COM add-in, but that's more complicated).

You can use the code found here to strip attachments with a button click:

http://www.slovaktech.com/code_samples.htm#StripAttachments

If you want to do this automatically try something like this code which would go in the Application_NewMail event.

Dim mNS as outlook.Namespace
Dim mFolder as outlook.mapifolder
dim objMsg as object


Set mNS as Application.GetNamespace("MAPI")
Set mFolder = mNS.GetDefaultFolder(olFolderInbox)
Set objMsg = mFolder.Items.GetFirst

            Set objAttachments = objMsg.Attachments
            attCount = objAttachments.Count
            If attCount > 0 Then
                For i = attCount To 1 Step -1
                    tmpFile = objAttachments.Item(i).FileName
                    tmpFile = "S:\AAGIS\Files\" & tmpFile
                    objAttachments.Item(i).SaveAsFile tmpFile
                    objAttachments.Item(i).Delete
                Next i
            objMsg.Save


0
 

Author Comment

by:quizzer
ID: 6966186
Thanks rj!!!!  rj where in Outlook is the Application_NewMail
event?
0
 
LVL 9

Expert Comment

by:rjcpjc
ID: 6966191
Open Outlook and hit ALT-F11.  That will open the VBA editor.  Its in ThisOutlookSession.
0
 

Author Comment

by:quizzer
ID: 6966225
We tried alt f11that and nothing happened.  We have Outlook 98 and we can't get to the VBA Editor
0
 
LVL 9

Expert Comment

by:rjcpjc
ID: 6966231
VBA is only supported in Outlook 2000 and higher (see first line of my initial response).  If you are using Outlook 98 then you cannot write code to do this when mail arrives unless you write an Exchange Event script and install it on the Exchange Server.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question