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

x
?
Solved

detaching attachment from email

Posted on 2002-03-13
13
Medium Priority
?
375 Views
Last Modified: 2010-05-02
is it possible to detach a file from an email which has been recieved automatically as the email arrives.

steps

1) computer has live email connection

2) outlook is loaded

3) software sitting there scanning email <- part of what I'm asking for

4) detects email and detaches the file.

Is this possible in VB or VBA,

rather have it in VBA

any idea's

cheers
Andy
0
Comment
Question by:andysalih
[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
  • 6
  • 6
13 Comments
 
LVL 53

Accepted Solution

by:
Ryan Chong earned 400 total points
ID: 6860171
Hi andysalih,

Recently give comments for a similar question, here is what the previous asker ask for:

Read the Inbox Folder to see if it's a New Email, if it got attachments, save it into specified directory:

Private Sub Command3_Click()
    Dim iOutlook As Outlook.Application
    Dim myitem As Outlook.MailItem
    Dim myFolder As Outlook.MAPIFolder
    Dim myAttach As Outlook.Attachment
    Set iOutlook = New Outlook.Application
   
    Set myFolder = iOutlook.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)

    List1.Clear
    For i = 1 To myFolder.Items.Count
        Set myitem = myFolder.Items(i)
        If myitem.UnRead = True And myitem.Attachments.Count > 0 Then 'If the Item is UnRead and With Attachment(s)
            List1.AddItem myitem.SenderName & " " & myitem.Subject
            For j = 1 To myitem.Attachments.Count
                Set myAttach = myitem.Attachments(j)
                myAttach.SaveAsFile "D:\" & myAttach.FileName
            Next j
            DoEvents
        End If
    Next i
    Set myitem = Nothing
    Set myFolder = Nothing
    Set iOutlook = Nothing
End Sub

You can simply put this in a Timer, assign an Internal, with a certain periods it will execute the code above.

ryancys
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6860173
To detect Internet Connection:

http://www.freevbcode.com/ShowCode.Asp?ID=632
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6860830
listening...
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Author Comment

by:andysalih
ID: 6861135
thanks all, I'm currently up to my eyes in programming for a company at the moment, so I will try the code in the next day or 2 to reward points,

PS

Will this work in VBA aswell ????

cheers

Andy

speak to you all soon
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6863381
Yes, basically this works in VBA also.

Make sure you add the M$ Outlook 9.0 Object Library from Reference and it should fine as well :)
0
 
LVL 3

Author Comment

by:andysalih
ID: 6864279
Thanks ryancys,

but it says when i try and run the code that the list1.additem box METHOD OR DATA OBJECT NOT FOUND which means that additem is not found for list1 properties, could this be moded to work in VBA.

cheers
Andy
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6864302
Sorry, In Access, combobox use RowSource Property rather that AddItem to add item to its list.

You can just ignore/ remark the line content: List1.AddItem

regards,
ryancys
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6864304
content = contain, bad english.. .
0
 
LVL 3

Author Comment

by:andysalih
ID: 6864901
thanks ryancys

could i put it in outlook vb editor under macros,

I've run it from there and its working but I dont understand how outlook can run the module automatically while outlook it open.

hmmm i dunno if you understood any of that.

you have been a great help even so, points will be rewarded even so.

cheers
Andy
0
 
LVL 3

Author Comment

by:andysalih
ID: 6864929
if you look under tools in outlook then macro's you will see visual basic editor,

could i put the code in there because thats where ive run it from and its working fine, but i want it to run upon receiving new email how do i make it run from that part of outlook

cheers
Andy
0
 
LVL 53

Expert Comment

by:Ryan Chong
ID: 6867609
Hi Andy,

So you want to auto-activate the save function when a new is received?

I'll try and get back to you :)
0
 
LVL 3

Author Comment

by:andysalih
ID: 6867641
yes please

many thanks

Andy
0
 
LVL 3

Author Comment

by:andysalih
ID: 6877593
Hi ryancys,

I've sorted it matey, just added it into outlook as a vba module,

thanks for your help

Andy
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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