B
bschanba
I want to have a random quote included in my signature file, and
included the code below in Outlook 2003 ThisOutlookSession class. It
works, but it is still causing the "A program is trying to access
e-mail addresses..." Huge thanks to Sue Mosher for all the info
posted. But I need clarification on this snippet:
However, Outlook 2003 does not show security prompts on three specific
types
of applications:
-- VBScript code in published, non-oneoff Outlook forms
-- Outlook VBA code that uses the intrinsic Application object
-- Outlook COM add-ins properly constructed to derive all objects
from the Application object passed by the OnConnection event
The vba code uses the intrinsic Application object, so it shouldn't be
showing the security prompt for that reason. Is this not correct, or
is there another reason this code gives the security prompt? Or if
anyone has another way of doing this same thing, I'd appreciate it.
Thanks in advance!
Option Explicit
Dim intQuotes As Integer
Dim strTop, strBottom, aryQuotes() As String
Dim WithEvents objInspectors As Outlook.Inspectors
Dim WithEvents objEmail As Outlook.MailItem
Private Sub Application_Startup()
Set objInspectors = Application.Inspectors
'top (consistant) part of signature
strTop = "My name and company here" & vbCrLf
'number of quotes in array below
intQuotes = 12
'random quotes in signature in zero-based array
ReDim aryQuotes(intQuotes) As String
aryQuotes(0) = "quote here"
'...
aryQuotes(11) = "another quote here"
'top (consistant) part of signature
strBottom = "bottom of signature here" & vbCrLf
End Sub
Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
If Inspector.CurrentItem.Class <> olMail Then Exit Sub
Set objEmail = Inspector.CurrentItem
End Sub
Private Sub objEmail_Open(Cancel As Boolean)
If objEmail.LastModificationTime <> "1/1/4501" Then Exit Sub
Dim intRandom As Integer, strSignature As String
intRandom = Int(intQuotes * Rnd())
strSignature = strTop & aryQuotes(intRandom) & strBottom
objEmail.Body = strSignature & objEmail.Body
End Sub
Private Sub Application_Quit()
Set objInspectors = Nothing
End Sub
included the code below in Outlook 2003 ThisOutlookSession class. It
works, but it is still causing the "A program is trying to access
e-mail addresses..." Huge thanks to Sue Mosher for all the info
posted. But I need clarification on this snippet:
However, Outlook 2003 does not show security prompts on three specific
types
of applications:
-- VBScript code in published, non-oneoff Outlook forms
-- Outlook VBA code that uses the intrinsic Application object
-- Outlook COM add-ins properly constructed to derive all objects
from the Application object passed by the OnConnection event
The vba code uses the intrinsic Application object, so it shouldn't be
showing the security prompt for that reason. Is this not correct, or
is there another reason this code gives the security prompt? Or if
anyone has another way of doing this same thing, I'd appreciate it.
Thanks in advance!
Option Explicit
Dim intQuotes As Integer
Dim strTop, strBottom, aryQuotes() As String
Dim WithEvents objInspectors As Outlook.Inspectors
Dim WithEvents objEmail As Outlook.MailItem
Private Sub Application_Startup()
Set objInspectors = Application.Inspectors
'top (consistant) part of signature
strTop = "My name and company here" & vbCrLf
'number of quotes in array below
intQuotes = 12
'random quotes in signature in zero-based array
ReDim aryQuotes(intQuotes) As String
aryQuotes(0) = "quote here"
'...
aryQuotes(11) = "another quote here"
'top (consistant) part of signature
strBottom = "bottom of signature here" & vbCrLf
End Sub
Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
If Inspector.CurrentItem.Class <> olMail Then Exit Sub
Set objEmail = Inspector.CurrentItem
End Sub
Private Sub objEmail_Open(Cancel As Boolean)
If objEmail.LastModificationTime <> "1/1/4501" Then Exit Sub
Dim intRandom As Integer, strSignature As String
intRandom = Int(intQuotes * Rnd())
strSignature = strTop & aryQuotes(intRandom) & strBottom
objEmail.Body = strSignature & objEmail.Body
End Sub
Private Sub Application_Quit()
Set objInspectors = Nothing
End Sub