Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2006-06-23
12
Medium Priority
?
1,104 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
  • 7
  • 3
10 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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
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 2000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

How to resolve IMCEAEX NDRs in Exchange or Exchange Online related to invalid X500 addresses.
If you troubleshoot Outlook for clients, you may want to know a bit more about the OST file before doing your next job. IMAP can cause a lot of drama if removed in the accounts without backing up.
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: …
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

877 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