Solved

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

Posted on 2006-06-23
12
1,081 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
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
 
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Sometimes Outlook might have problems sending a message. There may be various causes- corrupted PST, AV scanner etc. The message, instead of going to the Sent Items folder, sits in the Outbox indefinitely. To remove it you can use a free tool cal…
Are you unable to connect or configure Hotmail email account in Microsoft Outlook 2010, 2007? Or Outlook.com emails are not downloading to Outlook? Lets’ see the problem and resolve Outlook Connector error syncing folder hierarchy (0x8004102A).
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…
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…

760 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now