VBA & Outlook 2003 objMail.Send Security problem

J

Jeremy Melvin

I am wanting to take an incoming email from 'someone' and then resend it
automatically. I am using a Outlook Rule to start the VBA program when the
email comes in, and using the VBA program to copy the body and resend to a
mobile number.
I keep reading conflicting statements from my searches on the web and these
fourms about being able to send without getting the Security prompt from OMG.
Could some one please let me know if it is possible for me to do this using
the native VBA in Outlook by changing my code without using a third-party or
sendkeys program?
Here is my code:
Sub ForwardAsSMSTo12345(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim msgIn As Outlook.MailItem
Dim msgOut As Outlook.MailItem
strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set msgIn = olNS.GetItemFromID(strID)
Set msgOut = CreateItem(olMailItem)
msgOut.BodyFormat = olFormatPlain
msgOut.Subject = "From ML1500"
msgOut.Body = msgIn.Body
msgOut.To = "(e-mail address removed)"
msgOut.Send
Set msgIn = Nothing
Set msgOut = Nothing
Set olNS = Nothing
End Sub
 
K

Ken Slovak - [MVP - Outlook]

In Outlook 2003 using the intrinsic Application object you should not be
getting the security prompts at all. Are you getting those security prompts?
Is your computer locked down in a corporate setting? If it is then you'd
have to speak to your admins about changing the security settings in the
public folders security form.
 
J

Jeremy Melvin

Is my code using intrinsic application object? I don't know if I have that
set up correctly.
I have admin rights to my computer so I don't think that should be a
problem. I even tried to use Redemption code example I found, but every time
I get to "ObjMail.Send" it pops up the warning. I have my Macro setting at
medium, and have even made a digital cert for it. (no problem with the Macro
prompt)
I looked in the Security but I don't see anything that could stop it or
prompt.
Any Help would be appreciated. Let me know if you need any further
information from me. Thanks.
 
S

Sue Mosher [MVP-Outlook]

To determine whether your computer is locked down, as Ken describes, display the Help | About Microsoft Outlook dialog and check the Security Mode value. If it is "Administrator-controlled," your VBA code will be subject to security prompts unless you can persuade the network administrator to change that just for you -- highly unlikely.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
J

Jeremy Melvin

Thanks for that information. And it might help to clear up the problem as
well. I had THOUGHT that it was Outlook 2003, but it is actually Outlook
2002.. would that raise a different set of problems?

As for the Security Mode, it is Default.

I'll do some digging on Outlook 2002 and sending emails via VBA.. sorry
about that.
 
S

Sue Mosher [MVP-Outlook]

Yes, that makes all the difference in the world. Native VBA code will always raise prompts unless an Exchange administrator loosens security for you. The only solutions available to you as an individual are the third-party solutions listed at http://www.outlookcode.com/article.aspx?ID=52

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
S

Sue Mosher [MVP-Outlook]

That is, native VBA code in Outlook 2002.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


Yes, that makes all the difference in the world. Native VBA code will always raise prompts unless an Exchange administrator loosens security for you. The only solutions available to you as an individual are the third-party solutions listed at http://www.outlookcode.com/article.aspx?ID=52
 
J

Jeremy Melvin

Sue, Are you saything that "Security Mode: Default" is an elevated security
level? Or just that it being default is enough to always prompt me for auto
sending messages?
I will read more on the 3rd party solutions, but if I tried the Redemption
one and it still gave me a prompt, is that just me messing something up or is
it from the Security Mode: Default setting?

Thanks
 
K

Ken Slovak - [MVP - Outlook]

Security mode default is OK, it's your version of Outlook that's the
problem. In Outlook 2003 and later using Application and then deriving all
objects from that is trusted and won't raise the security. However, as I
mentioned before in Outlook 2002 and 2000 there is no trusted Application
object.

Your options are only what's listed on that reference that Sue gave you.

For send with Redemption you'd need something like this:

' if objMail is an Outlook.MailItem

Set safMail = CreateObject("Redemption.SafeMailItem")
safMail.Item = objMail

safMail.Send
 
S

Sue Mosher [MVP-Outlook]

I'm saying that because Outlook 2002 is the version, not 2003, the security mode is largely irrelevant. If I'd known that 2002 was the version in the first place, I wouldn't even have asked about it, and this discussion would have been much shorter because the answer to your original question would have been immediately apparent -- unless the Exchange administrator is your buddy, you need a third-party tool.

If you got a prompt while using Redemption, then you didn't use it correctly. Show some code, please. Or use what Ken posted.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
J

Jeremy Melvin

Sorry for the confusion and thanks for the help. Everything is working now
with Redemption and using a Rule for new incoming message from a specific
person. Here is the code I'm using.

Sub SendMobileAlert(Alert As MailItem)

Dim SafeItem, oItem
Set SafeItem = CreateObject("Redemption.SafeMailItem") 'Create an instance
of Redemption.SafeMailItem
Set oItem = Application.CreateItem(0) 'Create a new message

Dim objMail As MailItem
Dim AlertingMessage As Redemption.SafeMailItem

Set AlertingMessage = CreateObject("Redemption.SafeMailItem")

AlertingMessage.Item = Alert

SafeItem.Item = oItem 'set Item property
SafeItem.Recipients.Add "(e-mail address removed)"
SafeItem.Subject = "Subject Here"
SafeItem.Body = AlertingMessage.Body
SafeItem.Send

Set objMail = Nothing
Set Alert = Nothing
Set AlertingMessage = Nothing

End Sub
 

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