outlook macro

M

mc123

I recently had a request to be able to select a folder for re-directing sent
email. Basically when a user sends an email the user wants to be able to
have a pop-up telling the user where he/she would like the sent item to be
placed, this would be rather then the email going to the sent items folder.
I looked on the web and found a macro that would add this funcitonality. I
added the macro to the "ThisOutlookSession" object and saved the session when
exiting. This would work, but next time opening outlook the macro would not
work. I checked to make sure the macro was there and it was.

Note: I don't use macro's much

Any ideas? Thanks.
 
S

Sue Mosher [MVP-Outlook]

Check your security settings in TOols | Macro | Security and try restarting Outlook. Make sure it shuts down completely before you start it up again.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
M

mc123

That worked, now how would I keep my security settings and just allow this
one macro to run?

thanks.
 
S

Sue Mosher [MVP-Outlook]

I don't know, because you didn't tell us what, if anything, you actually did.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
M

mc123

Hey,
I have added the following macro in the VbaProject.OTM in the Object
"ThisOutlookSession"

Here is the macro/function:

Private Sub Application_ItemSend(ByVal Item As Object, _
Cancel As Boolean)
Dim objNS As NameSpace
Dim objFolder As MAPIFolder
Set objNS = Application.GetNamespace("MAPI")
Set objFolder = objNS.PickFolder
If TypeName(objFolder) <> "Nothing" And _
IsInDefaultStore(objFolder) Then
Set Item.SaveSentMessageFolder = objFolder
End If
Set objFolder = Nothing
Set objNS = Nothing
End Sub

Public Function IsInDefaultStore(objOL As Object) As Boolean
Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objInbox As Outlook.MAPIFolder
On Error Resume Next
Set objApp = CreateObject("Outlook.Application")
Set objNS = objApp.GetNamespace("MAPI")
Set objInbox = objNS.GetDefaultFolder(olFolderInbox)
Select Case objOL.Class
Case olFolder
If objOL.StoreID = objInbox.StoreID Then
IsInDefaultStore = True
End If
Case olAppointment, olContact, olDistributionList, _
olJournal, olMail, olNote, olPost, olTask
If objOL.Parent.StoreID = objInbox.StoreID Then
IsInDefaultStore = True
End If
Case Else
MsgBox "This function isn't designed to work " & _
"with " & TypeName(objOL) & _
" items and will return False.", _
, "IsInDefaultStore"
End Select
Set objApp = Nothing
Set objNS = Nothing
Set objInbox = Nothing
End Function

Basically if I remove the security then the macro will run and I get the
pop-up after sending e-mail, allowing me to select what folder the e-mail
will be placed in.
What I want to accomplish is to be able to keep the security on high and yet
be able to use this one macro. I assume I need to sign or add trusted
publishers?

Any ideas, thanks again.
 
S

Sue Mosher [MVP-Outlook]

You would need to create a certificate using the Selfcert.exe tool and then sign the macro project. See http://www.outlookcode.com/d/vb.htm#selfcert

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
M

mc123

Hey again,
I have tried to sign the macro with my own certificate but now am getting
the error:

"An error occurred while trying to sign the project. The unsigned project
has been saved"

Any ideas?

Thanks.
 
M

mc123

Hello again,

Ok, so what I did was to use SelfCert.exe and created another Certificate
that way. I was then able to save the Project and it now works. Question I
tried using my root certificate from my Certificate Authority that I created
myself with a windows CA (Stand alone), why would this not work?

Thank you.
 
S

Sue Mosher [MVP-Outlook]

Because the other cert probably wasn't a code-signing cert.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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