Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

VB and MS Exchange

Posted on 2002-03-05
3
Medium Priority
?
140 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 300 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

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

722 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