Selective Read Receipts VBA using run a script rule

G

Guest

Hello,

I'm running Outlook 2003 and would like the ability to always allow read
receipts from the users in my address book, but would like to choose whether
to allow a read receipt or not from anyone else. I'm attempting to do this by
setting the outlook settings to "always allow", but run the following a rule
on all incoming emails not in my contact list:

Sub PromptReadReceipt(MyMail As MailItem)
Dim strID, Display, Title As String
Dim olNS As Outlook.NameSpace
Dim Msg As Outlook.MailItem
Dim Style, Response

Display = "Do you wish to allow a read receipt?" ' Define message.
Style = vbYesNo ' Define buttons.
Title = "Read Receipt Prompt" ' Define title.

strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set Msg = olNS.GetItemFromID(strID)
If Item.ReadReceiptRequested = True Then
Response = Msgbox(Display, Style, Title)
If Response = vbNo Then
Item.ReadReceiptRequested = False
Item.OriginatorDeliveryReportRequested = False
Item.Update
End If
Else
End If
Else
End If

Set Msg = Nothing
Set olNS = Nothing
End Sub

I'm not very familiar with outlook and it's VBA code requirements, so I
Frankensteined this from code I found on multiple web pages and help menus. I
was hoping someone more experienced than I could have a look for errors/loops
before I try this out in Outlook.

Thanks!
 
G

Guest

Ammedment to code:

Knowing the email address of the sender would be useful to know before
authorizing a read receipt so I changed:

Display = "Do you wish to allow a read receipt?" ' Define message.

to:

Display = "Do you wish to allow a read receipt from " &
Item.SenderEmailAddress & "?"

Will this display the email address of the sender in the pop up box?

Thanks!
 
M

Michael Bauer

Am Wed, 24 May 2006 10:25:01 -0700 schrieb prideoflions:

Why don´t you simply test your solution yourself and ask if any errors
occur?
 
G

Guest

I'm usually a big trial and error kind of person, but I'm a little leery when
it comes to messing around with the gears of program as important as outlook.
I've never written a VB script for outlook before and half the code I'm using
is added because I saw it was necessary in examples, not because I actually
know what it does. That's hard to troubleshoot on your own.

Is there any files worth backing up or things I can do to minimize any
lasting issues? Are scripts harmless to play around with?

Prideoflions
 
M

Michael Bauer

Am Thu, 25 May 2006 09:37:02 -0700 schrieb prideoflions:

The only error I can see is:

- that the MailItem doesn´t support an Update method. instead is it called
Save.

- The method´s argument is called MyMail. Additionally you get the Msg
variable from that (which is good due to the security model). But then you
try to use the Item variable which is probably unkown.

- After Item.Update it contains one End If too much.

But that wouldn´t harm your data, it simply doesn´t run at all.

Additionally, no errors but that could be done better:

- The first Dim line doesn´t do what you´d expect. It declares the first two
variables probably as Variant (default) and only the last variable as
String.

- If there´re no commands between an Else and the End If then you don´t need
the Else statement.
 
G

Guest

Thanks!

That's just the kind of look over I needed. I now how a little better
understanding of the code I pieced together. I also changed "msg" with "Item"
in the declared variables so the code is makes more sense now.

I'm going to test out the script and if I encounter any further problems,
I'll start a new thread. If it runs just like I want it, I'll post the
completed code as general comments.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top