Solved

VB and MS Exchange

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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…
Suggested Courses
Course of the Month6 days, 14 hours left to enroll

623 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