script access to item.body warning

  • Thread starter Thread starter James B
  • Start date Start date
J

James B

I am writing a junk mail filter script and whenever I run
it I get the warning about the script trying to access
email addresses stored in outlook, it then askes do I
want to allow this, if I click yes the script runs as it
should, if no then the item.body call fails.

my question is why are the contacts searched or accessed
when i try to only get the body of a message? and is
there anyway to stop this message from coming up?
perhaps by getting access to the item.body another way?

I'm using XP, Outlook 2003, VS.NET installed, outlook
security level set to very high, my script is self signed
and in the trusted pubs list in outlook.

script is below

Sub FilterZeroBodyMail()
Set myOlApp = CreateObject("Outlook.Application")
Set myNameSpace = myOlApp.GetNamespace("MAPI")
Set inbox = myNameSpace.GetDefaultFolder(6)
Set junk = myNameSpace.Folders("Personal
Folders").Folders("Junk E-mail")

intMessCount = inbox.Items.Count

'myFolder.Folders.Get("

For x = 1 To intMessCount
Set Item = inbox.Items(x)
Body = Item.Body ' <--- warning pops up here
Body = Replace(Body, vbCrLf, "")
If Len(Trim(Body)) < 2 Then
Item.Move (junk)
MsgBox "Moving " & Item.Subject & " to junk
mail folder."
End If
Next x
End Sub
 
thanks, after reading through your site it seems there
is "no means to prove to Microsoft Outlook that their
programs (VBA) are safe, which would work with all
versions and configurations of Outlook", but is there a
way to allow only my script created on my machine to run
on my outlook 2003 without getting the access dialog?

also i can't select my macro as a script when creating a
new rule, do i have to do something special to my macro
before I am allowed to do this?
 
All the available solutions are listed on the page I suggested. Pay
attention to the information on coding for VBA and the use of the intrinsic
Application object.

A macro for use with Rules Wizard needs a MailItem argument:

Sub MyMacro(objMsg as MailItem)
' do stuff with objMsg
End Sub

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top