views:

203

answers:

3

Hey! I am following the code from microsoft from this page: http://support.microsoft.com/kb/306108

This is what I have:

Public Sub GetMails(Item As Outlook.MailItem)

    MsgBox "Mail message arrived: " & Item.SenderEmailAddress
    MsgBox "Mail message arrived: " & Item.Subject
    MsgBox "Mail message arrived: " & Item.Body

End Sub

I set a rule to run this macro on certain mails. What I get every time this script is run is a dialog nagging me about how a program is trying to access my mails. How can I get rid of this using VBA or is there any configuration option in Outlook I can turn off so that this does not appear?

I have googled for this and found some sites giving some code for C# and VB.net but none for VBA. Anyone knows how to fix this?

Thanks

+3  A: 

This was added to prevent malicious scripts from turning Outlook into a mass mailer or other bad things.

You can turn this off on your workstation, but if you want to distribute your application to other users, you can get rid of this only by creating your own Outlook Addin or use a 3rd-party tool like Redemption.

DR
A: 

Try this

Tools-->Macro-->Security-->macro security-->No security Tools-->Macro-->Security-->Programmatic Access

Then choose Never warn me about suspicious activity.

A: 

I found this somewhere and it works:

Sub SaveAttachment(myItem As Outlook.MailItem)

' Remove ay attachments for the email and save them in a ' local folder. If there are any erros on the saveing then ' attachments are left in place.

Dim myAttachments As Object
Dim myOrt As String
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim oMail As Outlook.MailItem
Dim fs As Object

' We need to get the mail item object from the application ' object to avoid warning messages

strID = myItem.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set oMail = olNS.GetItemFromID(strID)
Stuart