home | archives

Opinari.net

Opinari - Latin term for Opinion. Opinari.net is just what it seems: a cornucopia of rants, raves and poignant soliloquy.


Monday, March 01, 2004

Techie Alert, Evolution of the Circumvention of Bureaucracy:

One of the things that infuriates me about my employer is that I cannot use a .forward file to send my mail to my POP3 box. I can't always dial into the network, so an autoforward is a nice, elegant solution to my business problem.

Outlook has the ability to forward email using rules. However, rules that run on the client side do not perform as intended. No matter how many permutations of a "forwarded email" rule I have tried, they have failed.

So, enter the Outlook object model. I decided to write a routine that will check the MAPI folder and forward the email to whichever address is given in the Recipients.Add method. Below is the code:

Private Sub Application_NewMail()
Dim objItem As MailItem
Dim objMailItem As MailItem
Dim EmailAddress As String
Dim Subject As String
Dim Body As String

Set objItem = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items(1)

Subject = objItem.Subject & " From: " & objItem.SenderName
Body = objItem.Body

Set objMailItem = Application.CreateItem(olMailItem)

With objMailItem
.Subject = Subject
.Body = Body
.Recipients.Add "email@server.com"
.Send
End With

Set objMailItem = Nothing
End Sub


It worked well, except for one thing. Read receipts. Anytime I received a Read receipt, the program crashed. Error 13. Type mismatch.

What to do...?

Check Outlook object model again. Nothing about identifying message types. Managed to find the MessageClass object, but nothing in the documentation about how to explicitly identify message types. (Stupid documentation!)

Proceed to plan B. Ask everyone you know. Nothing.

Plan C? Well, maybe there's something in the Exchange documentation. Indeed there is. It turns out that "REPORT.IPM.NOTE.IPNNRN" and "REPORT.IPM.NOTE.IPNRN" identify the two different types of Read receipts in MAPI. So I added a single If - Then statement after the Set object statement:

If UCase(objItem.MessageClass) = "REPORT.IPM.NOTE.IPNNRN" Or _
UCase(objItem.MessageClass) = "REPORT.IPM.NOTE.IPNRN" Then
Exit Sub
End If


Eureka. Now email is automatically forwarded to me.

The moral to this story?

1. Bureaucracy sucks.
2. MS documentation (aside from .NET) sucks.

Life as an IT pro. Take it, or leave it.

Labels:

.: posted by Dave 2:53 PM





Need ASP.NET, VB, VB.NET, or Access development?

Contact me through Guru.com.




Opinari Archives


Recommended Reading


Blogroll Me!












Proudly blogging on a Treo 650 using Vagablog 1.9.

This page powered by Blogger, and yours should be, too!