Hey guys
I'm trying to import Email folder but I can't find a way to import the attachment as well
Knowing that there is a cell that determines whether there is an attachment or not
So what I need is a code to be associated to a button that can show the attachment(s)
5 3904
I guess "importing it" implies some preferred destination, which in your case I cannot speak to. But here is how you can save an email attachment. If you want to show it, it will depend on the file type and what tool or program you use to show/open the file.
Here's a slice of code I wrote. I've pulled some selected lines out of a block of code and added the necessary next/ends for this quick reply - Dim Folder As Outlook.MAPIFolder
-
Dim SubFolder As Outlook.MAPIFolder
-
250 For Each Folder In objNSpace.folders
-
260 For Each SubFolder In Folder.folders
-
270 For Each UserFolder In SubFolder.folders
-
280 For Each objItem In UserFolder.Items ' myFolder.Items
-
290 If objItem.Class = olMail Then
-
Dim objMail As Outlook.MailItem
-
300 Set objMail = objItem
-
-
380 For Each att In objItem.Attachments
-
390 bSkip = False
-
400 If objMail.ReceivedTime <= rsEmail!LastEmailReceived Then
-
410 att.SaveAsFile Path_and_Fname
-
420 End If
-
end if ' objitem.class=olMail
-
next objitem
-
next userfolder
-
next subfolder
-
next folder
-
I changed the UserFolder.Items to Inbox.Items however it didn't work
If you can help of how it use the code or where can I assign it to let it work
I am also confused as to what you mean by 'Import', but the following Code will: - Create an Instance of Microsoft Outlook.
- Access the Default Inbox.
- Loop thru every Email in the Inbox.
- If the Email contains 1 or more Attachments, Print and sequentially number the Emails to the Immediate Window.
- Perform some basic Cleanup Chores.
- Obviously, change to suit you specific needs.
- Code Definition:
- 'Must set a Reference to the Microsoft Outlook XX.X Object Library
-
Dim appOut As Outlook.Application
-
Dim olNS As Outlook.Namespace
-
Dim oFldr As Outlook.MAPIFolder
-
Dim oItem As Outlook.MailItem
-
Dim oAtch As Outlook.Attachment
-
Dim intNumOAttch As Integer
-
Dim intCtr As Integer
-
-
Set appOut = New Outlook.Application
-
Set olNS = appOut.GetNamespace("MAPI")
-
Set oFldr = olNS.GetDefaultFolder(olFolderInbox)
-
-
For Each oItem In oFldr.Items
-
If oItem.Attachments.Count > 0 Then
-
Debug.Print oItem.Subject
-
For intCtr = 1 To oItem.Attachments.Count
-
Debug.Print " |-- " & Format$(intCtr, "00") & ": " & oItem.Attachments(intCtr)
-
Next
-
Debug.Print "---------------------------------------------------------------------------------"
-
End If
-
Next oItem
-
-
Set oFldr = Nothing
-
Set olNS = Nothing
-
Set appOut = Nothing
- Sample OUTPUT:
- Video Project request process
-
|-- 01: Video Production Request Form.pdf
-
|-- 02: Video Edit Request Form.pdf
-
|-- 03: Production Release Form.pdf
-
--------------------------------------------------
-
Phone list
-
|-- 01: My Contacts Phone List 19-20.docx
-
--------------------------------------------------
-
Vacation Photos (September 2020)
-
|-- 01: image077.jpg
-
|-- 02: image013.jpg
-
|-- 03: image014.jpg
-
|-- 04: image015.jpg
-
|-- 05: image016.jpg
-
|-- 06: image017.jpg
-
|-- 07: image018.jpg
-
|-- 08: image019.jpg
-
|-- 09: image020.jpg
-
--------------------------------------------------
-
FW: RE: Accessibility issues for people who can't wear masks
-
|-- 01: image002.jpg
-
|-- 02: image003.png
-
|-- 03: image004.png
-
|-- 04: image005.png
-
|-- 05: image006.png
-
|-- 06: image007.png
Thanks a lot for the reply
What I'm doing is I'm trying to collect emails using ms access, so at the beginning I've used the import from external data option to get the email folder into a table in access and then I created a form to be able to see the email contents, sender ... etc.
However if there is an attachment in the mail I don't know how to preview it within the access form.
adding to this I don't know to what exactly do I assign the code.
- Save each Attachment to Disk using the SaveAsFile() Method of the Attachment Object
- Created a Related Table to your EMail Table that stores the Absolute PATHs to the previously saved Attachments. A Foreign Key in this Table will Link to the EMail Table.
- You can create a Sub-Form on you Main Form that will contain the Attachment Information
- Using any of several Methods, clicking on an Attachment Record in the Sub-Form will open that Attachment.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: bruce |
last post by:
I can send an email from any client (outlook, lotus notes), and fill
it with all sorts of fonts (bold, courier, etc). When the mail is
received, the client reads it inline, not as an attachment.
...
|
by: Andrew Chan |
last post by:
Dear All,
I'm new in VS C++.I would like to write a c++ program that can be send
email with attachment,and all the input will be call from a file (
such as To Email address, attachment path).
...
|
by: Alexander |
last post by:
To all,
A tall order, but any help on any segment of this would be
appreciated:
I have a table that needs to be populated with information contained
in an email attachment.
1. Is it...
|
by: Lee |
last post by:
As the subject states, I have been playing in the system trying to
figure out a method of using a report as the email body text.
So far, the closest I have come is the acFormatHTML. However,...
|
by: Darin |
last post by:
Currently, our software is creating an email message using the Outlook
DLL to send emails out that have PDF attachments. I want to stop forcing
the customer to use outlook to send email.
So, I...
|
by: PollyAnna |
last post by:
Hi,
I am fairly new to .Net and would appreciate some help.
How do I open an email and its attachment programmatically.
Once I have done this, is it a straightforward operation to then just...
|
by: Hanika |
last post by:
Going on 3 days and I am wodnering if I am just not looking in the right
place. If anyone nows how to do this please please help me.
I am developing a Windows form application using VB.NET 2005....
|
by: Cylix |
last post by:
My application have a file list,
I set the the list will drag the file fullpath string already.
When I drop it to outlook email, it pasted as a text ...
How can I paste it as a attachment?
...
|
by: wpflum |
last post by:
I'm using Net::POP3, Email:Simple and Email::Mime to pull emails off of a server and parse them for information to see if they are the result of 'bounced' emails from our system. I then send an email...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
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...
|
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...
|
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...
|
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: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |