Solved

VB and MS Exchange

Posted on 2002-03-05
3
137 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
[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 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…

751 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