Solved

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

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Create high volume marketing opportunities using email signatures with these top 10 DOs and DON'Ts of email signature marketing.
Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
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…

743 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

10 Experts available now in Live!

Get 1:1 Help Now