random signature vba assistance

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
 
B

bschanba

Thanks (one post too late) to Eric Legault for his code in his update
to "Insert random signature" on 2/10/03. I used selfcert.exe as
instructed in other posts to keep outlook macro security on high with
my own certificate. But I didn't find a way to not have the warning
pop up when I am going to send an email. I did't want to use an addon
that will remove the warning completely (even for other programs trying
to access outlook), rather just remove the warning when I've clicked on
compose/reply/forward. For now I'm just clicking on yes, allow access
(annoying but tolerable.)...at least until I find out more details
about the intrinsic Application object. :)
 
B

bschanba

Thanks (one post too late) to Eric Legault for his code in his update
to "Insert random signature" on 2/10/03. I used selfcert.exe as
instructed in other posts to keep outlook macro security on high with
my own certificate. But I didn't find a way to not have the warning
pop up when I am going to send an email. I did't want to use an addon
that will remove the warning completely (even for other programs trying
to access outlook), rather just remove the warning when I've clicked on
compose/reply/forward. For now I'm just clicking on yes, allow access
(annoying but tolerable.)...at least until I find out more details
about the intrinsic Application object. :)
 
B

bschanba

Thanks (one post too late) to Eric Legault for his code in his update
to "Insert random signature" on 2/10/03. I used selfcert.exe as
instructed in other posts to keep outlook macro security on high with
my own certificate. But I didn't find a way to not have the warning
pop up when I am going to send an email. I did't want to use an addon
that will remove the warning completely (even for other programs trying
to access outlook), rather just remove the warning when I've clicked on
compose/reply/forward. For now I'm just clicking on yes, allow access
(annoying but tolerable.)...at least until I find out more details
about the intrinsic Application object. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top