473,320 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Access & Outlook

Hi all,

Im creating a database which has a table linked to an email account. so far i can only get the table to show wether or not an email has an attachment but i cant find away of opening/importing them.

Anyone know how?
Jul 3 '08 #1
3 1035
debasisdas
8,127 Expert 4TB
can you pass more information please.
Jul 3 '08 #2
can you pass more information please.
What im ideally looking for is some Access code that will allow me to detach the files from emails (linking them using the table mentioned) and save them to a local drive.
Jul 3 '08 #3
This could do with tidyign up a bit but it seems to do the job!


Expand|Select|Wrap|Line Numbers
  1. Dim oOutlook As Outlook.Application
  2. Dim oNs As Outlook.NameSpace
  3. Dim oFldr As Outlook.MAPIFolder
  4. Dim oAttachments As Outlook.Attachments
  5. Dim oAttachment As Outlook.Attachment
  6. Dim iMsgCount As Integer
  7.  
  8. Dim oMessage As Outlook.MailItem
  9.  
  10. Dim iCtr As Long, iAttachCnt As Long
  11.  
  12. Dim sFileNames As String
  13. Dim aFileNames() As String
  14.  
  15.  
  16. 'get reference to email folder
  17. Set oOutlook = New Outlook.Application
  18. Set oNs = oOutlook.GetNamespace("MAPI")
  19. tolfolder = "Mailbox - Bower, Phil X" 'Top folder
  20. myfolder = "Important" 'email folder
  21. Set oFldr = oNs.Folders(tolfolder).Folders(myfolder)
  22.  
  23.  
  24.  
  25. Debug.Print "Total Items: "; oFldr.Items.Count
  26. Debug.Print "Total Unread items = " & oFldr.UnReadItemCount
  27.  
  28.  
  29. For Each oMessage In oFldr.Items
  30.  
  31.     With oMessage
  32.         'basic info about message
  33.         If .UnRead = True Then
  34.             Debug.Print .To
  35.             Debug.Print .CC
  36.             Debug.Print .Subject
  37.             Debug.Print .Body
  38.             iMsgCount = iMsgCount + 1
  39.             With oMessage.Attachments
  40.                 iAttachCnt = .Count
  41.                 If iAttachCnt > 0 Then
  42.                     For iCtr = 1 To iAttachCnt
  43.                         'UID will need replacing with unique identifier for record in DB
  44.                         .Item(iCtr).SaveAsFile "C:\" & UID & "\" & .Item(iCtr).FileName
  45.                     Next iCtr
  46.                 End If
  47.             End With
  48.             .UnRead = False
  49.         End If
  50.     End With
  51. Next oMessage
  52.  
  53.  
  54. End Sub
Jul 3 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Dave | last post by:
I have been reading everything i can find regarding sql mail and sql agent mail. We have a win2k server, sql 2000 and NO, NO, NO exchange server(all up to date on service packs). I have tried...
20
by: wolftor | last post by:
Would anyone be willing to beta test my application for me and give me some feedback? I can give you feedback in exchange (ie. if there are parts you're interested in knowing how it was done) or I...
47
by: ship | last post by:
Hi We need some advice: We are thinking of upgrading our Access database from Access 2000 to Access 2004. How stable is MS Office 2003? (particularly Access 2003). We are just a small...
6
by: David Anderson | last post by:
Does anyone know how to drag&drop a message with attachments from Outlook (2002 or 2003) in to a VB.Net windows form. This is really stumping me. I've spent a fair amount of time trying to find a...
3
by: wizzbangca | last post by:
Hi everyone. Having problems with a utility I am writing for work. The previous IT Director thoughtfully allowed 3 (2000, xp, 2003) versions of outlook to be installed rather than 1. Now I need...
2
by: mik.sjoblom | last post by:
Hello, I have developed a Access application that needs to read mail from Outlook, versions on Access and outlook are 2003. In the code i use mapi to connect to outlook. When i tries to read the...
1
by: Crash | last post by:
I am having a tough time finding documentation on DASL! 1) What the heck does DASL stand for - I can't even find any documentation on that? Anyway, I would like to integrate a DASL query into my...
11
by: mike_solomon | last post by:
Hi I have a link on a website that if you click opens up outlook <button onClick="location.href='mailto:a@b.com?subject=test subject'" > Select</button> Works fine But I want to include...
10
by: Walshi | last post by:
Hi all, I'm a relative newby to access and VBA etc. My forms and tables etc are working great and saving lots of time...However... I have two databases with the exact same table format. I want...
0
by: Roman Optio | last post by:
Hi, I am currently working on a tool to transfer addressbook data such as contacts and organizations between Vondle and Outlook. For those of you who are wondering what Vondle is, it is an...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.