Solved

Printing multiple e-mails with multiple attachments in consequitive order.

Posted on 2006-06-23
12
1,095 Views
Last Modified: 2008-03-10
I need to be able to print out multiple e-mails (which have multiple attachments of various types) in consequitive order out of Outlook 2003.
i.e. (1) E-mail no.1 (2) attachment no.1(word) to e-mail no.1 (3) attachment no.2(excel) to e-mail no.1 (4) E-mail no.2 (5) attachment no.1(pdf) to e-mail no.3 (6) attachment no.2(bmp) to e-mail no.2

Any ideas? Thanks.
0
Comment
Question by:jrctl
[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
  • 7
  • 3
12 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 16971153
Hi jrctl,

I can modify the code from this question (http://www.experts-exchange.com/Applications/MS_Office/Outlook/Q_21473712.html) to do this.  Is that what you're looking for?

Cheers!
0
 

Author Comment

by:jrctl
ID: 17001229
Hi again.

Hmmm maybe. I have a viewer that we possibly could use "C:\Program Files\Interwoven\WorkSite\view32.exe" that allows us to to view doc types. The problem with this app is that each document needs to be active in it in order to print out. i.e. you cannot select a range of documents and print the whole range.

Thanks.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 17004750
Let me know how you want to proceed and we'll take it from there.
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 76

Expert Comment

by:David Lee
ID: 17065927
Hi, jrctl.

Any progress?
0
 

Author Comment

by:jrctl
ID: 17147635
No, not as yet. I don't seem to be getting anywhere. The problem is if we set the viewer to be the deafult application it still doesn't get around the printing in order issue. We could try the viewer but I think that it will only solve one of the issues.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 17147938
What about modifying the code to the question I linked to?
0
 

Author Comment

by:jrctl
ID: 17152607
That was my original question as well! Yes, this could work but if only you can ensure the timing of the file openings. As it stands, your script converts all HTML e-mails to rich text and then prints of the e-mails with their linked attachments - which is great. The problem with this, however, is that there does not seem to be any mechanism to ensure that all attachments to   e-mail no.1 are printed out in order before e-mail no. 2 and it's attachments are printed out. If you can solve this then great!!!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 17152701
I pretty sure I can make it work that way.  I'll test to make sure and get back to you.
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 17166068
I had a second look at the code from the other question and it looks to me like it will do what you want with minor modification.  The code I posted prints the open message and all attachments, so we need a modification that prints all selected messages, not just the open message.  The other issue is printing everything in sequence.  The messages will be handled in sequence and so will the attachments, but there is one factor I can't control.  Let's say a message has two attachments.  Attachment A is a Word document that's 20 pages long.  Attachment B is a small text file.  The code runs and prints the message then fires the command to print the Word document.  Word takes a moment to load and because the file is 20 pages long it's going to take several seconds to print.  In the meantime the code has moved along to the next attachment, the small text file, and ordered it to print.  The text file is probably going to appear before the Word document has finished.  I don't see any way to get around that.  There is no "tell an attachment to print and wait for it to finish before moving on" command.  I could through a Sleep command in to pause code execution immediately after the print, but that's not a good solution.  A large or complex document might take longer that then length of time I tell the code to sleep for, in which case we're back to having a problem, and items that print quickly will waste time while the code sleeps before printing the next item.  The only other approach would be to write a routine that would watch the queue of the printer the jobs are going to and watch for each one to finish before printing the next one.  That's possible, but it's certainly more complex and therefore more prone to problems.  Another alternative would be to pop up a dialog-box saying that attachment X has been sent to the printer and have you click a button to move on to the next item.  I expect that's not a good option.

Here's the modified code for printing all selected messages and their attachments.  Let me know how you'd like to proceed and we'll take it from there.

Sub PrintMessageAndAttachments()
    Dim objItem As Object, _
        objFile As Object, _
        strTempFolderPath As String, _
        strFilename As String, _
        objShellApp As Object, _
        objFolder As Object
    'Change the path on the next line to one that can hold temp files
    strTempFolderPath = "C:\eeTesting\Temp\"
    Set objShellApp = CreateObject("Shell.Application")
    Set objFolder = objShellApp.NameSpace(strTempFolderPath)
    For Each objItem In Application.ActiveExplorer.Selection
        If objItem.Class = olMail Then
            objItem.PrintOut
            For Each objFile In objItem.Attachments
                strFilename = strTempFolderPath & objFile.FileName
                objFile.SaveAsFile strFilename
                objFolder.ParseName(objFile.FileName).InvokeVerb ("&Print")
            Next
        End If
    Next
    Set objFile = Nothing
    Set objItem = Nothing
    Set objFolder = Nothing
    Set objShellApp = Nothing
End Sub
0
 
LVL 76

Expert Comment

by:David Lee
ID: 17220747
Any update, jrctl?
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Outlook Free & Paid Tools
How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

696 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