PDA

View Full Version : Word / outlook issue



Snowflake
10-17-2012, 09:10 AM
I am trying to send a mail from a doc using this:

Dim OL As Object
Dim EmailItem As Object
Dim Doc As Document
Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Doc = ActiveDocument
Doc.Save
With EmailItem
.Subject = "For you"
.Body = "Best regards!"
.To = "cal23@yahoo.com"
.Attachments.Add Doc.FullName
.Display
.Send
End With
End Sub

When I try to send it gives me a warning message:"A program is trying to automatically send e-mail on your behalf etc."

Is it possible to bypass this?

Btw, I am using Outlook 2003.

Very weird..:(

Frosty
10-17-2012, 12:53 PM
This is a security setting, to prevent malicious word vba macro viruses from sending a whole bunch of emails without your knowledge.

Can't give you a specific answer on how to avoid this issue, as it is highly depending on your corporate environment. Here is a link with more info.

http://www.pcreview.co.uk/forums/program-trying-automatically-send-email-t828678.html

Snowflake
10-17-2012, 01:19 PM
Is there some sort of a VBA code for outlook OR word which would bypass this issue?

Frosty
10-17-2012, 01:21 PM
If there was, it wouldn't be much of a security measure, would it?

Snowflake
10-17-2012, 01:32 PM
If there was, it wouldn't be much of a security measure, would it?

I found this

OlSecurityManager.DisableOOMWarnings = True
On Error Goto Finally
' ... any action with protected objects ...
Finally:
OlSecurityManager.DisableOOMWarnings = False

I don't know if I should put it in the outlook because it doesn't seem to work, but maybe I am doing it all wrong..

Sooo annoyyiiing

Frosty
10-17-2012, 01:37 PM
I'll shorten your search for an answer: there is no answer in the realm of custom VBA code within outlook or word.

You either need a COM addin with a valid security certificate or you need to talk to your exchange administrator or you need to live with clicking yes on the security warning.

You really should read the link I provided. I didn't post it so that I could read it-- it contains the information you're looking for, which is that what you're trying to do cannot be done in the way you are trying to do it.

Why can't you use built in functionality to do what you're trying to do? What are you trying to do (besides make a security measure disappear that you can't make disappear with some variation of the code you have displayed)?

Snowflake
10-17-2012, 01:45 PM
If only it wouldn't take so long for the yes button to appear. :(
I've read that and couple of similar links. None of which helped me anyway..

I thought you guys here know stuff they don't publish on google, so I tried..

Frosty
10-17-2012, 02:15 PM
It will only take long the first time-- if you click Yes and select 10 minutes... it should be fast for the next 10 minutes.

I can't speak to what "we" know vs. "google" -- but this is just the way it is (and has been, since Word 2002, SR2, if I recall correctly).

fumei
10-17-2012, 06:20 PM
Since Outlook 2002 SR2 (technically speaking it is not a Word issue).

Snowflake, even though the link posts comments from Sue Mosher (who really knows Outlook)

-- 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

please note that this means Outlook VBA code - which means you can NOT use Word VBA code, even code that makes calls to the Outlook application object model.

As Frosty has pointed it, it would be a pretty useless security feature if you could bypass it easily.

Snowflake
10-17-2012, 10:05 PM
-- 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

How to apply it to outlook properly?
So there is a VBA code for outlook which disables the warning?

Frosty
10-18-2012, 12:46 AM
No. There is no VBA code for outlook to disable this warning. But there is a different way of generating emails via VBA code which do not trigger the warning, because they are "safe" ways of doing stuff. Whether these other ways are helpful to you or not will require considerably more info from you. Also, there is a much different deployment model for outlook VBA than there is for word VBA.

So, as I said before--- there is no code to solve the problem you have described. I'm sorry. Do you want to try and solve a different problem? Do you want to try and articulate your "real" problem?

Fumei is quoting the pertinent areas of that link, but I suspect none of it is really making much sense because you don't have the experience to understand it. That's why I'm keeping it simple.

However, there are often many ways to accomplish something...

Snowflake
10-18-2012, 09:19 AM
Fumei is quoting the pertinent areas of that link, but I suspect none of it is really making much sense because you don't have the experience to understand it. That's why I'm keeping it simple.

However, there are often many ways to accomplish something...

Well, yeah, I have no experience at all..

If it's impossible to accomplish it with Office 2003/Sp2 then I am lost anyway..

You guys can write VBA for everything, I know that, but if this is an outlook issue then I was mislead..not your fault..

fumei
10-18-2012, 11:34 AM
It is impossible (and rightly so). I seriously doubt you were misled. That implies someone attempting to deceive. You perhaps misunderstood, in which case the responsibility is yours.

That being said, ClickYes may - repeat MAY - be able to help. If you can still find it. I have no experience using it, as I never attempt to bypass security.

Snowflake
10-18-2012, 01:37 PM
It is impossible (and rightly so). I seriously doubt you were misled. That implies someone attempting to deceive.

I was mislead by the material I found online. VBA for this, VBA for that etc., but nothing would work anyway..

Nothing to do with this forum, at least here I found the answer..

Frosty
10-18-2012, 01:43 PM
Thank link actually specifically said ClickYes didn't work anymore. Basically, this was a security loop hole that Microsoft closed.

You *can* use VBA to automate processes by which you send emails from Microsoft Word without security violations, but not in the way that you're doing it. There are built-in "safe" processes that Microsoft has provided (mail merges will allow you to generate emails). However, in 2003 those processes are (in my opinion) a little clunky in that it doesn't allow you to necessarily review the emails before they get sent... but you won't pop up a security dialog.

But you'd need to specify what you are actually trying to accomplish as a task, since the code you posted is simply not possible to adapt in order to avoid the security measures Microsoft has but in place since Outlook 2002 R2 (and, as I've said a few times-- if it was able to be adapted, then all the malicious virus creators would simply be delivering their spam-email macro viruses using that adapted code-- they are just as good, or better, at searching google for those kinds of solutions as regular folks).

I don't think you've found your answer yet, Snowflake... but I also don't think you've yet asked the right question...

fumei
10-18-2012, 02:44 PM
"I was mislead by the material I found online."

So you are saying whatever you read was deliberately there to mislead? Or...you just did not read it correctly? I would be interested in seeing what it is you found online.