Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email problem with Outlook XP

Status
Not open for further replies.

RichardH

Programmer
Apr 21, 2001
46
0
0
US
I have been using code similar to this to create a bulk email for everyone in the table mydatabase:

scan
oApp = createObject("Outlook.Application")
oMail = oApp.CreateItem(0)
oMail.to=alltrim(mydatabase.emailaddress)
oMail.subject = "Subject here"
oMail.body = "Email body test here"
oMail.send()
release oApp
release oMail
endscan

It works great with Outlook 2000 but with Outlook XP it has problems. I get a couple of messages and the user is forced to press the "Yes" button for each message to be sent. Here are the messages:

"A program is trying to send mail using Item.Send

A program is trying to automatically send email using a Microsoft Outlook Visual Basic command, Item.send. If you want this program to send this email, click Yes. To stop the program click No. If you are unsure which program is sending the email or why, you may want to click No to avoid any possible spread of viruses.

Note: when this message is displayed the Yes button is not available for 5 seconds"

Then a box appears where you can press Yes or No. The big problem is that the user has to wait 5 seconds and press Yes for each email.

I think I understand what Microsoft is trying to do here but hope there is a way around it without asking users to go back to Outlook 2000.

Thanks for any help.
 
There are two ways of doing this that I know of :

1. There is a DLL in Windows XP and Windows 2000 (wich can be installed on a Win98 Machine) that allows use to send e-mails bypassing outlook altogether (thereby bypassing this security check) Please see faq184-1768

2. There is an Outlook MVP that wrote a fix called outlook redemption v1.1 please see this link :

Hope that helps
 
Thanks mgagnon,

You seem to have the solutions I am looking for but hopefully you or someone else can give me just a bit more help.

I like the CDO.dll solution best becuase it doesn't require that my users install a patch, BUT I get an error when I try to use it on a Windows XP machine. I don't have Win98 to test with and am not sure if you indicated it would only work on Win98.

This is the exact code I am using:

oMSG = CREATEOBJECT("cdo.message")
oMSG.To = "brian@museumsoftware.com"
oMSG.From = "rick@museumsoftware.com"
oMSG.Subject = "Hello Email"
oMSG.TextBody = "This is an easy way to create an email"
oMSG.Send()

I get the error when it attempts to execute the line
oMSG.Send()

The error message says:
&quot;OLD IDispatch exception code 0 from?: The server rejected one or more recipient addresses. The server response was 550 relaying to <brian@museumsoftware.com> prohibitied by administrator.&quot;

Any ideas on what is wrong here would be most apprecieated.
-----------------

I also tried to use the Outlook Redemtion solution and need some help. They provide the following VB code example but I am not good at translating that to VFP. Could someone tell me the equivalent Foxpro code.

Here is the VB code:

dim SafeItem, oItem
set SafeItem = CreateObject(&quot;Redemption.SafeMailItem&quot;)
set oItem = Application.CreateItem(0)
SafeItem.Item = oItem
SafeItem.Recipients.Add &quot;somebody@somewhere.com&quot;
SafeItem.Recipients.ResolveAll
SafeItem.Subject = &quot;Testing Redemption&quot;
SafeItem.Send

Thanks again for the help.
 
Regarding the CDO.dll, I'm trying to re-create your problem. I did a test e-mail sending it to myself, and I don't get that error . Windows XP, Outlook XP.

 
Mgagnon...Thanks again.

Still struggling here. I am using VFP 6.0 Windows XP (Home) and Outlook XP. I performed a search for &quot;CDO.dll&quot; and it doesn't exist on this computer. Is there anything else I need to install or look for?

Once again this is the exact code:

oMSG = CREATEOBJECT(&quot;cdo.message&quot;)
oMSG.To = &quot;brian@museumsoftware.com&quot;
oMSG.From = &quot;rick@museumsoftware.com&quot;
oMSG.Subject = &quot;Hello Email&quot;
oMSG.TextBody = &quot;This is apparently NOT an easy way to create an email&quot;
oMSG.Send()

I still get the same error on the oMSG.Send() command.

Thanks....
 
The VB code would translate to VFP as:
Code:
LOCAL SafeItem, oItem  
SafeItem = CreateObject(&quot;Redemption.SafeMailItem&quot;) 
oItem = Application.CreateItem(0) 
SafeItem.Item = oItem  
SafeItem.Recipients.Add( &quot;somebody@somewhere.com&quot; )
SafeItem.Recipients.ResolveAll 
SafeItem.Subject = &quot;Testing Redemption&quot; 
SafeItem.Send
 
wgcs - thanks for the translation, but unfortunately that code doesn't work for me. I get the following error on the line &quot;oItem = Application.CreateItem(0)&quot;

&quot;OLE error code 0x80020006 Unknown name.&quot;

I installed the software of &quot;Redemtion for Outlook&quot;. Does anyone know why I can getting this error.

Thanks....
 
RichardH

>. I performed a search for &quot;CDO.dll&quot; and it doesn't exist >on this computer. Is there anything else I need to >install or look for?

The Colaboration Data Objects (CDO) dynamic link library (DLL) comes with Microsoft Office 2000 (or XP) but I think it does not install automatically.
Here is the download page link:
 
Hi Guys,

The CDO DLL name is CDOsys.dll and/or CDOnts.dll. I've been trying to use code similar to what you are doing. We want to send emails from production machines to an email server without having to configure Outlook on said production machines. We don't want that hassle or overhead. I can't get the code snippets to work for me either.


Allen &quot;Uncanny&quot; Schott
 
>>>>>>>>>>>>
The CDO DLL name is CDOsys.dll and/or CDOnts.dll. I've been trying to use code similar to what you are doing. We want to send emails from production machines to an email server without having to configure Outlook on said production machines. We don't want that hassle or overhead. I can't get the code snippets to work for me either.
>>>>>>>>>>>>>
Funny I did a searche my HD and found a CDO.dll.
 

Playing around with the Redemption sample, I stumbled across the solution to the &quot;unknown name&quot; error. Simply add a line at the beginning to instantiate Outlook, like this:

local OutlookItem, SafeItem, oItem
OutlookItem = CreateObject(&quot;Outlook.Application&quot;)
SafeItem = CreateObject(&quot;Redemption.SafeMailItem&quot;)
oItem = OutlookItem.CreateItem(0)
SafeItem.Item = oItem
SafeItem.Recipients.Add( &quot;somebody@anywhere.com&quot; )
SafeItem.Recipients.ResolveAll
SafeItem.Subject = &quot;Testing Redemption&quot;
SafeItem.Send

It sends the message without intervention.


Mike Krausnick
 
I forgot to mention in my last post, that while researching this problem (amazingly, I logged on to solve the exact same problem today!) I ran across Microsoft's reason for not loading CDO in Windows 2000 (KB Article Q262634):

&quot;Collaborative Data Objects (CDO)
CDO is another object model that people who write viruses can use to send mail. The Microsoft Outlook 98 update removes CDO from your system to take away this risk, but the Outlook 2000 update cannot remove CDO. Microsoft recommends that you manually uninstall CDO by using the Add-Remove tool in Outlook or Office Setup. &quot;

I presume they mean &quot;can use to infect computers&quot; rather than &quot;can use send mail&quot;, since sending mail is not a particularly nefarious activity. In any case, CDO is a security vulnerability.

Mike Krausnick
 
mkrausnik, THANK YOU!

I may be be near solving this problem. I was able to acutually send an email using the &quot;Redemption&quot; and the code you supplied. I do have a couple of more questions if you don't mind giving me more help.

1. How do I add the text or body of the email?

2. It seems to default the senders email address to my email address(I am not sure how it knows that). Is there a way to change the senders address?

3. Is there a way to send one email addressed to multiple email addresses?

4. One strange thing happens, after the email is sent my default drive is changed from where I was in my program application to:

c:\program files\commonfiles\system\mapi\1033.

I guess I can add a command that will put me back where I need to be, but was wondering what was going on there.

I haven't had a chance to try your suggestions for the CDO method yet, but that is my prefered method so hope it works.

Thanks again..
 
Still struggling.

I installed CDO from the original Office XP Professional CD, since it was not installed by default. But I still get the same error as before on the oMSG.Send() command.

&quot;OLD IDispatch exception code 0 from?: The server rejected one or more recipient addresses. The server response was 550 relaying to <brian@museumsoftware.com> prohibited by administrator.&quot;

It seems that the evil virus senders have once again made my life a living hell. We use this bulk email feature to send invoices to are clients who are very happy to participate in saving trees.

I really hope there is a way outa here.
 
RichardH

Have you tried send a test e-mail with CDO to someone outside your own domain?
Sounds like you you are not permitted to relay within your own domain.
 
RICHARDH

Of course there is always the MAPI Ssssion:
* Create an instance of a form, and then add the MSMAPI.MAPISession and
* MSMAPI.MAPIMessages OLE controls to that form:

oform = CreateObject(&quot;form&quot;)
oform.addobject(&quot;Session1&quot;,&quot;olecontrol&quot;,&quot;MSMAPI.mapiSession&quot;)
oform.addobject(&quot;Message1&quot;,&quot;olecontrol&quot;,&quot;MSMAPI.mapiMessages&quot;)

* Call the Signon method of the MAPISession control. If the user is not
* logged into mail, this will prompt the user to sign on. This also sets
* the SessionId property for the MAPIsession control:

oform.Session1.signon

* Set the SessionId of the MAPIMessage control to the SessionId of the
* MAPISession control, which was just obtained:

oform.Message1.sessionid = oform.Session1.sessionid

* Compose an e-mail message and set the subject line and Message text:

oform.Message1.compose
oform.Message1.msgsubject = &quot;Memo from my FoxPro app&quot;
oform.Message1.msgnotetext = &quot;This works&quot;

* Sends the e-mail message. The (1) is required to send the message.

oform.Message1.send(1)

* Optionally, sign off from mail:

oform.Session1.signoff

* Optionally, release the objects if they are no longer needed:

release oform
 
Hi All,

I recently picked up WWIPStuff from It allows you to send mail directly to a SMTP server without using Outlook. I have clients running Terminal Services/Citrix and this solution really helped. No setting up Outlook profiles. Very easy to integrate and the price was right.

I am not sure if it would fit, but you might want to look at it.

Matt
 
mgagnon..Thanks again,

Unfortunately still no luck. I have tried the CDO with the recipient outside my domain with the same bad results.

The MAPI Ssssion may work, but I would need some more code. You example doesn't have a place to enter the recipients email address and just brings up Outlook with a message started to noone. How could it be used to Automatcially send multiple emails?

I guess I will give West Wind a look $199 sounds like a very cheap solution at this point.

Thanks all for hanging in here with me.....Rick


 
FWIW:

Answering your questions from yesterday:
1. The properties not documented in Outlook Redemption are not security-related and so you use the Outlook properties -i.e:
oMsg.Body = &quot;Message Text&quot;
for message text.
2. You assign the sender the same way; I think the property is oMsg.Sender or oMsg.SenderName. You can probably also use Redemption's SentOnBehalfOf property.
3. You add additional recipients using oNewMsg.Recipients.Add( <recipientemailaddress> ), the same as with Outlook.
4. I also discovered that the directory got changed but I didn't research where exactly it was happening.

I ran my code change by Dmitry Streblechenko, the author of Outlook redemption. He response follows:
=========
Mike,
Your code is correct. But I'd name OutlookItem Application instead and add a couple extra lines required if Outlook is not yet running:

local OutlookItem, SafeItem, oItem, Namespace
Aplication = CreateObject(&quot;Outlook.Application&quot;)
Namespace = Aplication.GetNamespace(&quot;MAPI&quot;)
Namespace.Logon
SafeItem = CreateObject(&quot;Redemption.SafeMailItem&quot;)
oItem = Aplication.CreateItem(0)
SafeItem.Item = oItem
SafeItem.Recipients.Add( &quot;somebody@anywhere.com&quot; )
SafeItem.Recipients.ResolveAll
SafeItem.Subject = &quot;Testing Redemption&quot;
SafeItem.Send
====

I didn't try his suggestion yet, but with some treaking, that might solve the sender name problem.

As a last resort, I tried re-installing Office, thinking it would re-install without the security update. No such luck.

Good luck with the Westwind solution. I'm going to switch my computers around so the one doing the emailing doesn't have the security patch installed. That will get me going until I can rewrite the routines using Simple MAPI, which according to Microsoft, doesn't have the security problem.

Mike Krausnick






Mike Krausnick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top