How to open PDF attachement upon arrivel new mail

Status
Not open for further replies.

jepe63

Member
Outlook version
Email Account
POP3
Hello, i've got a little problem ;)

I'm using a pc fax to receive my faxes, then they automatically are mailed to my mail address and i get them in a normal mail with the fax as an PDF attachment.

Is there a way to open this attachment automatically when this mail is received , so i can see this fax directly on my screen without every time to have to open the mail and then the attachment ?

Greetz, and thx for the help !
 
Get the code at Print Outlook email attachments as they arrive - Slipstick Systems and change "print" to "open" in the code. Add .pdf (and/or remove.doc or .xls)

Hi , thanx for the fast respons , unfortunally i'm doing something wrong because it't not working.

I first am trying the macro as it is (printing) , deal with openening later.

I've added this to see if macro is running , and got a confirmation , so that should be ok.
MsgBox "Welcome, " & Application.GetNamespace("MAPI").CurrentUser
Application.ActiveExplorer.WindowState = olMaximized

but if i receive a mail with an "doc" attachement , nothing happens, no printing...what could be wrong ?

Is it maybe because i'm using the dutch version of 2010 or doesn't this matter ?

Greetz and thx !
 
Is it a doc or a docx?

This line controls which attachments print - you need the *last 4 characters* for each file type.

Case ".xls", ".doc"

To add pdf and docx, you would use

Case ".xls", ".doc", ".pdf", "docx"
 
Is it a doc or a docx?

This line controls which attachments print - you need the *last 4 characters* for each file type.

Case ".xls", ".doc"

To add pdf and docx, you would use

Case ".xls", ".doc", ".pdf", "docx"

I used the original script you wrote and used a email with a .doc file , nothing changed yet...

Is the language of outlook an issue ?
 
maybe i can test my vba with a little script (just opening mail on arrival ) ?
 
I don't think language is the issue - it was written in German originally.

I used this code - and opened pdf and docx

Code:
' This code looks at the last 3 characters in a filename 
 
' Change it to 5 to work with docx and xlsx files
     sFileType = LCase$(Right$(oAtt.FileName, 4))
     Select Case sFileType 
 
' Add additional file types below
     Case ".xls", ".doc", "docx", ".pdf"
       sFile = ATTACHMENT_DIRECTORY & oAtt.FileName
       oAtt.SaveAsFile sFile
       ShellExecute 0, "open", sFile, vbNullString, vbNullString, 0
     End Select
   Next
 End If 
 
End Sub
 
that's very strange, maybe something wrong with my vba ?

although it's giving me the Welcome Fax message as programmed...

MsgBox "Welcome, " & Application.GetNamespace("MAPI").CurrentUser
Application.ActiveExplorer.WindowState = olMaximized
 
Are you printing or opening? I'm only testing it with open. While print will work, it will use the default printer and that could be causing your problems.
 
i'm using the open command, just tested on a different pc (with office 2007) but also no opening PDF's .:confused:
 
oke, did a little test with a script that i found on internet.

Sub ChangeSubjectForward(Item As Outlook.MailItem)

Item.Subject = "Test"
Item.Save

Set myForward = Item.Forward

myForward.Recipients.Add "myemailaddress@mymail.com" (real address used of course ;) )

myForward.Send

End Sub

and the result = nothing

i'm getting desperate , what's happening ? :(
 
oke is now working on my outlook 2010 but got 2 more questions

only working in 'standard' inbox , how can i get it in my second 'fax' inbox ?

secondly , i'm making this for outlook 2007 to and got there an 'ShellExecute' sub of function is not difined error ?
 
You said the msgbox worked, right? So that means the other macro is working - VBA is enabled, the Application_Start up is working.

The change subject macro is used with run a script - it should work too, if you made a rule. You can change the myforward.send part to myforward.display - if it works, a message opens on screen. That way you don't actually have to send anything.

If any parts of the macro are red, it won't work, but VBA should tell you something is wrong - it'll highlight the text in yellow and outlook is basically locked until you take care of the macro.

Does the filepath exist? in the code has d:\attachments.

I'm assuming word is installed? <g> In my test Outlook 2007 system, it wasn't. There is no error handling to tell us when something fails - it just ends.

Now, while all of that is things that can go wrong... it's not opening the file on my test system either. The macro is saving the file in MyDocuments and when i added a msgbox to show the filename, it displays it but the shell open command is not running. I'll have to look at it closer this evening - I need to hit the grocery store.
 
Yea, I've narrowed it down to something with either 2007 or winxp (my test system) - the startup not firing is not the problem here - the macro is running, so it is firing. It's not doing the shellexecute though.

I'm not getting the undefined error - I'm not getting any error.
 
Oké, thanks Diane !

I found the shellexecute error, the text at the top of the script was messed up , so i copied it again and "hoera" (dutch for yeeeeeh ;) ) everthing is working.

Now when i receive a email with an attached PDF it opens perfectly !!!

One question tough, i've got 2 folders in my email , one is the normal 'inbox' , the other is called 'fax' , this script is only working in 'inbox' , how do i get it working in another folder ?
 
to clarify my previous post , the scrip is now working on the 'red' arrow (the normal inbox called 'Postvak In ' in dutch , but i should work on the 'green' arrow folder 'Postvak In' under folder named 'FAX' ;) FAX.jpg

I hope this make sense, that's why i included picture ;)
 
Oke , figured this one out...thx to another post i found of you ;)

Thx for all the help !!!

You restored my fait in people again by doing this completely free , you're trully a wonderful woman !

Greetings from Belgium ;)

Werner
 
oke , this is getting addicting !! ;)

is it possible to do this at 2 folders at once ?
 
I'll take a look at it later today. I'm leaving on a business trip and may not have time to get on the computer for next 12 hours.
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Commodore PDF attachments started to open in Edge Using Outlook 0
B Auto open PDF Outlook VBA and Custom Forms 0
R how to open a pdf file with a known password Outlook VBA and Custom Forms 1
G Get current open draft message body from VBA Outlook VBA and Custom Forms 1
Rupert Dragwater How to get Outlook 365 to open from websites Using Outlook 5
Witzker Outlook 2019 Edit contact from email does not open the user defined contactform Using Outlook 3
S Leaving ActiveExplorer open for editing after Sub is done Outlook VBA and Custom Forms 0
T Outlook 2021 Cannot open attachments Outlook DeskTop 2021 Using Outlook 0
X Open Hyperlinks in an Outlook Email Message (Help with Diane's solution) Outlook VBA and Custom Forms 3
S HTML Code Embedded in String Within Open Outlook Email Preventing Replace(Application.ActiveInspector.CurrentItem.HTMLBody From Working Outlook VBA and Custom Forms 4
talla Can't open Outlook Item. Using Outlook 0
O Outlook on Android: after sharing / sending a news article, draft remains open. Why? Using Outlook 1
K Embedded photos no longer open with Photos or Photo Viewer Using Outlook 7
Witzker Open Contact missing in Outlook 2019 Using Outlook 2
L Cannot open PST file for first session each day Using Outlook 6
A How to open a specific link automatically with outlook 2016 Outlook VBA and Custom Forms 6
H Upon opening Outlook, make my popmail inbox open instead of outlook.com inbox Using Outlook 1
sahameed82 SharePoint calendar directly open in Outlook Using Outlook 0
N .pst archive from work will not open/import on Microsoft 365 Exchange Server Administration 0
C Outlook 2016/2019 hangs after being open for an extended period Using Outlook 4
M Where is the setting to *turn off* open calendar in a new window? Using Outlook 3
W Automatically open attachments without automatically printing them Using Outlook 0
Y Open and Save Hyperlink Files in multiple emails Outlook VBA and Custom Forms 9
J How to open OST file in Outlook 2019 & 2016 Using Outlook 1
C Can't Open Outlook 365 Using Outlook 0
D after delete mail, open the next one Outlook VBA and Custom Forms 0
N VBA Script to Open highlighted e-mail and Edit Message Outlook VBA and Custom Forms 5
M outlook won't open! Using Outlook 1
N Open & Save VBAProject.Otm using VBA Code Outlook VBA and Custom Forms 1
E Unable to open Outlook 2010 after adding new email account Using Outlook 4
M other user's mailbox won't open, forms disappeared Using Outlook 42
S SendFromAccount - Problem trying to test existing value in open email Outlook VBA and Custom Forms 2
J Open an outlook email by Subject on MS Access linked table with VBA Outlook VBA and Custom Forms 10
D Add Tetxbox at form open Outlook VBA and Custom Forms 1
U Catching ModuleSwitch events after "open in new window" Outlook VBA and Custom Forms 2
Andrew Quirl Open attachment, manipulate without add-on program? Outlook VBA and Custom Forms 5
S Reminder Dialog Open Button Using Outlook 2
A How to open a specific link automatically with outlook Outlook VBA and Custom Forms 13
S Outlook 2010 Cannot Open Attachments Using Outlook 14
N open the hyperlink in Outlook directly instead of browser Using Outlook 1
S Outlook does not open the .pst file created by the Outlook Using Outlook 5
A open Outlook with multiple windows. Using Outlook 0
K open calendar from address book Outlook VBA and Custom Forms 1
T Double clik behavior on agenda open a new meeting request Using Outlook 1
E Open olNoteItem Attachment Outlook VBA and Custom Forms 6
G Can't open .pst. Message could not access default folder (Outlook 2010 (.pst). Before that was backi Using Outlook 0
I Outlook 2010, 2013 will not open .msg or .eml files Using Outlook.com accounts in Outlook 1
Diane Poremsky Outlook VBA: Work with Open Item or Selected Item Using Outlook 0
O Windows 10 x64 Outlook 2013 - URL does not open (anymore) Using Outlook 3
Hudas VBA find and open an email without looping thru each email in the inbox Outlook VBA and Custom Forms 1

Similar threads

Back
Top