G
Greg
I am trying to write a couple of simple macros for Microsoft Outlook.
When I run the macros either manually or based on a rule when new email
is received I get a popup security warning that "A program is trying to
access e-mail addresses you have stored in Outlook "
I am running Microsoft Outlook 2003 on Windows 2000. I would like to
stop the popups from aplearing as it gets annoying to have to click ok
each time and I would like the first macro to run in the background on
selected emails on receipt. Is there a way to do this direct from VBA
without purchasing a 3rd party product?
Below are the macros I am trying to run
Macro #1: called by a rule when mail is received
Sub testMacro1(MyMail As MailItem)
Dim x As String
Dim strID As String
'------------------------------------------------------------------------
Dim muOlApp As Outlook.Application
'------------------------------------------------------------------------
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim mySubj, myMsg, mySender, myMsg2 As String
Dim rs As ADODB.Recordset
Dim fld As ADODB.Field
Dim sql As String
strID = MyMail.EntryID
(I have tried the following two lines and the line commented out below
them with the same results)
'------------------------------------------------------------------------
Set myOlApp = Application
Set olNS = myOlApp.GetNamespace("MAPI")
'------------------------------------------------------------------------
'Set olNS = Application.GetNamespace("MAPI")
Set olMail = olNS.GetItemFromID(strID)
mySubj = olMail.Subject
myMsg = olMail.Body (POPUP MESSAGE)
mySender = olMail.SenderEmailAddress (POPUP MESSAGE)
Set olMail = Nothing
Set olNS = Nothing
End Sub
Macro#2: Called manually from the toolbar
Sub addNewReq()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim fld As ADODB.Field
Dim sql As String
Dim x As Long
Dim tst As String
mybody = ActiveInspector.CurrentItem.Body
mySubj = ActiveInspector.CurrentItem.Subject
mySender = ActiveInspector.CurrentItem.SenderEmailAddress
If InStr(1, mySender, "@") = 0 Then
x = InStrRev(mySender, "=")
mySender = Right$(mySender, Len(mySender) - x)
End If
end sub
I would appreciate any suggestions.
When I run the macros either manually or based on a rule when new email
is received I get a popup security warning that "A program is trying to
access e-mail addresses you have stored in Outlook "
I am running Microsoft Outlook 2003 on Windows 2000. I would like to
stop the popups from aplearing as it gets annoying to have to click ok
each time and I would like the first macro to run in the background on
selected emails on receipt. Is there a way to do this direct from VBA
without purchasing a 3rd party product?
Below are the macros I am trying to run
Macro #1: called by a rule when mail is received
Sub testMacro1(MyMail As MailItem)
Dim x As String
Dim strID As String
'------------------------------------------------------------------------
Dim muOlApp As Outlook.Application
'------------------------------------------------------------------------
Dim olNS As Outlook.NameSpace
Dim olMail As Outlook.MailItem
Dim mySubj, myMsg, mySender, myMsg2 As String
Dim rs As ADODB.Recordset
Dim fld As ADODB.Field
Dim sql As String
strID = MyMail.EntryID
(I have tried the following two lines and the line commented out below
them with the same results)
'------------------------------------------------------------------------
Set myOlApp = Application
Set olNS = myOlApp.GetNamespace("MAPI")
'------------------------------------------------------------------------
'Set olNS = Application.GetNamespace("MAPI")
Set olMail = olNS.GetItemFromID(strID)
mySubj = olMail.Subject
myMsg = olMail.Body (POPUP MESSAGE)
mySender = olMail.SenderEmailAddress (POPUP MESSAGE)
Set olMail = Nothing
Set olNS = Nothing
End Sub
Macro#2: Called manually from the toolbar
Sub addNewReq()
Dim conn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim fld As ADODB.Field
Dim sql As String
Dim x As Long
Dim tst As String
mybody = ActiveInspector.CurrentItem.Body
mySubj = ActiveInspector.CurrentItem.Subject
mySender = ActiveInspector.CurrentItem.SenderEmailAddress
If InStr(1, mySender, "@") = 0 Then
x = InStrRev(mySender, "=")
mySender = Right$(mySender, Len(mySender) - x)
End If
end sub
I would appreciate any suggestions.