Solved

VB and MS Exchange

Posted on 2002-03-05
3
136 Views
Last Modified: 2010-05-02
I am looking to create a routine that will extract any attachments that come into an exchange mailbox.  For example, we have a weekly timesheet that is filled out in excel.  It is then emailed to the administator.  The only mail that is coming into this box are the timesheets.  What we are wanting is that once the attachment is recevied in the box, it will save to a network share.

1) Would this be done at the time the mail is received in the box or at the time it is received in outlook?

2)  Once determined when, how would it be done?


Any help is appreciated.

Thanks
0
Comment
Question by:GTLoner
3 Comments
 
LVL 28

Accepted Solution

by:
vinnyd79 earned 75 total points
ID: 6844191
In regards to your second question ....
This will extract all attachments from the inbox.
First you will need to add a reference to the Outlook Object Library,then create a form with a command button.
This example assumes you have a folder called C:\Attachments to save the files to.You might want to modify this to delete the mail item after saving the attachment.You might also want to check if the attachments exists before saving otherwise an attachment with the same name will get overwritten.Do the timesheets have different names? Do you need to save these files as soon as they arrive? If not maybe you can use a timer routine to run every 5 minutes or so?

Private Sub Command1_Click()
Dim oApp As Outlook.Application
Dim oNameSpace As NameSpace
Dim oFolder As MAPIFolder
Dim oMailItem As Object
Dim sMessage As String

Set oApp = New Outlook.Application
Set oNameSpace = oApp.GetNamespace("MAPI")
Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
For Each oMailItem In oFolder.Items
With oMailItem
If oMailItem.Attachments.Count > 0 Then
  On Error Resume Next
  oMailItem.Attachments.Item(1).SaveAsFile "C:\Attachments\" & oMailItem.Attachments.Item(1).FileName
End If
End With
Next oMailItem

Set oMailItem = Nothing
Set oFolder = Nothing
Set oNameSpace = Nothing
Set oApp = Nothing
End Sub

0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7591796
Hi GTLoner,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept vinnyd79's comment(s) as an answer.

GTLoner, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:modulo
ID: 7624119
Finalized as proposed

modulo

Community Support Moderator
Experts Exchange
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

713 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