2

I am following the code from this page: How to create a script for the Rules Wizard in Outlook

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. Every time this script runs there is a dialog 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 so that this does not appear?

I have googled for this and found some sites giving code for C# and VB.net but none for VBA.

Community
  • 1
  • 1
AntonioCS
  • 8,335
  • 18
  • 63
  • 92

3 Answers3

5

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.

Daniel Rikowski
  • 71,375
  • 57
  • 251
  • 329
1

Try this

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

Then choose Never warn me about suspicious activity.

0

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
  • 1,008
  • 11
  • 14