Link to home
Start Free TrialLog in
Avatar of dprager
dprager

asked on

Renaming E-mail attachment in outlook or thunderbird

Hi Guys,

Here's my problem. I have a standalone computer and a server. both run the same database. On the server the SQL database in synchronized with a program called DBsinc to the ms access database.
I also have changes on my computer and need some way to update the database on the server and update my own database from the server database. I know this is not the way I should approach this problem but it looks like it's my only option for the moment.
Due to security reasons where I work it is not possible to go around this using FTP. That means my only way out is by using email. I have written some code to automatically send an email and attached a table with the necessary update data. Now I need some way to get the attachment out of the email with VBA. Im currently using Thunderbird witch has the option to store attachments in a different folder on the computer. Unfortunately it refuses to do so.

What I need to know is how to isolate a attachment from an email and save it in a specified folder. Using thunderbird, outlook or any other program I can easily download is just fine.
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

As an exampole see her for outlook.

Any clarification or tweaking required then of course ask.

Chris
ASKER CERTIFIED SOLUTION
Avatar of Chris Bottomley
Chris Bottomley
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dprager
dprager

ASKER

Thanx,

The code you gave me Works perfect. There are just a few little things that need to alter.

The code only removes the attachments of the selected emails and puts them in the specified folder entered in the input box. Im lazy so I dont want to open Outlook explorer and select the specified email.

Is there a way in the code to select all of the emails listed in inbox and replace all of the attachments of the email messages there? I think I should alter the code listed below but I dont really know how.

Second of all I get a message that program is trying to alter my emails ( can I get rid of this annoying message ? )

On Error Resume Next
   
    'work on selected items
    Set myOlExp = myOlApp.ActiveExplorer
    Set myOlSel = myOlExp.Selection ( needs to be all emails  in inbox in this line)
   
    'for all items do...
    For Each myItem In myOlSel
   
        'point on attachments
        Set myAttachments = myItem.Attachments
       
        'if there are some...
        If myAttachments.Count > 0 Then
       
1. To select all items:
change
    Set myOlExp = myOlApp.ActiveExplorer
    Set myOlSel = myOlExp.Selection ( needs to be all emails  in inbox in this line)
     
    'for all items do...
    For Each myItem In myOlSel
to
    Set myOlExp = myOlApp.ActiveExplorer
    Set myOlSel = myOlExp..getnamespace("MAPI").getdefaultfolder(6)
   
    'for all items do...
    For Each myItem In myOlSel.items

Ought to do it.

2. Pesky message, assuming 2003 or earlier then personally I find  mapilab to be ideal but see:
You can modify your code to use redemption:
http://www.dimastr.com/redemption/

You can use an outlook add-in i.e:
http://www.mapilab.com/outlook/security

Or finally you can use clickyes
http://www.contextmagic.com/

ANy help?

Chris

 
Avatar of dprager

ASKER

Thanx again,

But don't have it working yet. The counter stays empty in some strange way. Could you please take a look at the attached screenshot.

< i >  is empty so the VB code gets caught in an infinite loop and the program crashes.



Avatar of dprager

ASKER

Thanx again,

But don't have it working yet. The counter stays empty in some strange way. Could you please take a look at the attached screenshot.

< i >  is empty so the VB code gets caught in an infinite loop and the program crashes.




SCR.JPG
Looks alright albeit I don't have 2000.

If you set a watch on i, and step through the delete block how does it look on entry and on each step?

Chris
The other thing is use the mechanism:

for i = myattachments.count to 1 step -1
     save it
     delete it
next

Chris
Avatar of dprager

ASKER

Thanx, it took me a while to get corking the way I wanted it to but it works great now !!

Thanx Defenitly worth full points !!
Glad to be of some help and thank you for the grade.

Chris