Solved

programmatically print outlook attachments (server-side)

Posted on 2004-03-26
4
504 Views
Last Modified: 2010-03-05
Is it possible to programmatically print outlook attachments (server-side) for an email account?
0
Comment
Question by:froggy_bill
  • 2
4 Comments
 
LVL 1

Expert Comment

by:ktuffner00
Comment Utility
you can by creating a sript or by using a third party tool to do this, but ive never done it.  check the microsoft newsgroups for exchange or slipstick.com.  Im sure someone has done it.  The best would be a script in my way.  Ive also heard from other people in the field about third party software that does this
0
 
LVL 10

Expert Comment

by:OneHump
Comment Utility
You definately would have to program.  I think the the operative term here is "server side".  The only way to do this server side is by running the app, along with a MAPI subsystem (client) on the server.  That may not be desireable for performance reasons.  You could definately run your app against the server from a remote location.

You can definately do this though.  The best approach would be one of two things:

1.  An event script that hooks into a print control.

2.  A VB script or application that uses a MAPI control to pull down messages, place them into an array and print using a print control.

None of this is hard.  The hard part is doing this if you don't know VB or VBScript.

OneHump
0
 
LVL 2

Expert Comment

by:timiano
Comment Utility
Dim Rec
Dim Rs
Dim strURL
Dim strQ
Dim strSubj
Dim DomainName
Dim strLocalPath
Dim UnreadCount

Set Rec = CreateObject("ADODB.Record")
Set Rs = CreateObject("ADODB.Recordset")

DomainName = "domain.internal"
strUser = "usernam"
strPwd = "password"

strLocalPath = "MBX/" & strUser & "/inbox"

strURL = "file://./backofficestorage/" & DomainName & "/" & strLocalPath
'Response.Write "strURL= " & strURL


Rec.Open strURL,,,,,strUser,strPwd

' Build the SQL query for the messages.
strQ = "select "
strQ = strQ & " ""urn:schemas:mailheader:date"""
strQ = strQ & ", ""urn:schemas:httpmail:to"""
strQ = strQ & ", ""urn:schemas:httpmail:from"""
strQ = strQ & ", ""urn:schemas:mailheader:subject"""
strQ = strQ & ", ""urn:schemas:mailheader:received"""
strQ = strQ & ", ""urn:schemas:httpmail:read"""
strQ = strQ & ", ""DAV:contentclass"""
strQ = strQ & ", ""DAV:href"""
strQ = strQ & " from scope ('shallow traversal of "
strQ = strQ & Chr(34) & strURL & Chr(34) & "')"
'strQ = strQ & " WHERE ""urn:schemas:httpmail:hasattachment"" = true"

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile("C:\TextFileToLogOutputTo.log")

' Open the recordset.
Rs.Open strQ, Rec.ActiveConnection

Rs.MoveFirst
Unreadcount = 0

' Loop through all of the messages in the recordset and format them in a table.
Do Until Rs.EOF

objFile.WriteLine Rs.Fields("urn:schemas:httpmail:from").Value & "," & _
      Rs.Fields("urn:schemas:httpmail:to").Value & _
      Rs.Fields("urn:schemas:mailheader:subject").Value & _
      Rs.Fields("urn:schemas:mailheader:date").Value & _
      Rs.Fields("urn:schemas:mailheader:date").Value & _
      Rs.Fields("DAV:contentclass").Value & _
      Rs.Fields("DAV:href").Value
Rs.MoveNext


' Close the record and recordset.
Rs.Close
Rec.Close

You have to use this logged on as the particular user, or as a user with full mailbox access to the account in question.  This will output to a text file that you specify.  I have used this for other purposes before, but with different criteria.  http://msdn.microsoft.com/library/en-us/cdosys/html/_cdosys_schema_httpmail.asp explains the rest of the fields that can be accessed via ADO/CDO.

Timiano
0
 
LVL 2

Accepted Solution

by:
timiano earned 500 total points
Comment Utility
Oh, and take out the  ' I put on the line with the hasattachment query.....sorry!
0

Featured Post

Are end users causing IT problems again?

You’ve taken the time to design and update all your end user’s email signatures, only to find out they’re messing up the HTML, changing the font and ruining the imagery. What can you do to prevent this? Find out how you can save your signatures from end users today.

Join & Write a Comment

We are happy to announce a brand new addition to our line of acclaimed email signature management products – CodeTwo Email Signatures for Office 365.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this video we show how to create a Shared Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Sha…
In this video we show how to create an email address policy in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Mail Flow…

762 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

11 Experts available now in Live!

Get 1:1 Help Now