Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Retrieve mail & attachments (programmatically)

Posted on 2003-02-28
2
Medium Priority
?
166 Views
Last Modified: 2010-05-01
Each day I’m (now) being sent an email with a data file as an attachment. I’d like to get the attached file, parse it, and write it to Access. The part that I can’t figure out yet is how to retrieve the email and the attached file using a script. Does anyone know of an object I can set that’ll do this?

Thanks in advance
Colin West
0
Comment
Question by:cwest1
2 Comments
 
LVL 3

Accepted Solution

by:
DocM earned 150 total points
ID: 8045547
Here is one way to do it with the MAPISession and the MAPIMessages components from Microsoft MAPI Controls.

Private Sub Save_EMail()
   Dim MIndex As Integer
   
   If MAPISession1.SessionID = 0 Then MAPISession1.SignOn
   With MAPIMessages1
       .SessionID = MAPISession1.SessionID
       .FetchSorted = True
       .FetchUnreadOnly = True
       .Fetch
       For MIndex = 0 To .MsgCount - 1
           If .MsgOrigAddress = "<Sender's email address>" Then
               MsgAttachmentName = .AttachmentName
               If MsgAttachmentName <> "" Then
               Open MsgAttachmentName For Input As #3
                While EOF(3) = False
                 AttachedFileContent = Input(FileLen(MsgAttachmentName), 3)
                 'Do what you want with AttachedFileContent
                Wend
               Close #3
               End If
        End If
       Next MIndex
   End With
   Close #1
   MAPISession1.SignOff
End Sub
0
 

Expert Comment

by:CleanupPing
ID: 8940425
cwest1:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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 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…
Suggested Courses
Course of the Month10 days, 13 hours left to enroll

572 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