Solved

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

Posted on 2002-04-24
5
433 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
  • 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Resolve Outlook connectivity issues after moving mailbox to new Exchange 2016 server
Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now