Page 1 of 2

Problem with OLE and Outlook 2007

Posted: Fri Apr 20, 2007 1:09 pm
by driessen
Hello,

I use this code to send email from my application :

Code: Select all

oOutLook := CreateObject("Outlook.Application")
oMail  := oOutLook:CreateItem(olMailItem)
oMail:Subject := ALLTRIM(EmOnde)
oMail:Body    := ALLTRIM(FmText)
oMail:Recipients:Add(cEmail[i])
oMail:CC  := TabCC
oMail:BCC := TabBCC
FOR j=1 TO LEN(TabBijl)
    oMail:Attachments:Add(TabBijl[j])
NEXT
oMail:HTMLBody := MEMOREAD(ALLTRIM(US->UOUTLSJAB))
oMail:Send()
When I was using Outlook 2000, XP or 2003, everything went just fine. Now I just started using Outlook 2007. If Outlook 2007 is opened, no problems occurs but if Outlook 2007 is not opened, I got an error :
Error discription : E_FAIL:Recepients

Win32ole => TOLEAUTO:RECIPIENTS
To prevent the error from happening, I have to open Outlook 2007 before I run my application.

But this wasn't the case with Outlook 2000, XP or 2003. I didn't need to open Outlook before running my application.

Can anyone tell me how this problem can be solved ?

Thank you.

Re: Problem with OLE and Outlook 2007

Posted: Fri Apr 20, 2007 1:16 pm
by Enrico Maria Giordano
Probably a bug in Outlook 2007. Can't you just open Outlook using ShellExecute() before your sendmail code?

EMG

Posted: Sat Mar 08, 2008 3:08 pm
by Otto
Michel, how did you resolved the problem.

Thanks in advance
Otto

Posted: Sat Mar 08, 2008 10:34 pm
by NK
Have you test this way ?

Code: Select all

      oOutLook := CreateObject( "Outlook.Application" )
      oMail := oOutLook:CreateItem( 0 )
      oRecip := oMail:Recipients
      oRecip:Add( AllTrim( cTo ) )
Regards, Norbert

Posted: Sun Mar 09, 2008 8:58 am
by Otto
Norbert, thank you for your help.
But if Outlook - tests with VISTA and Office 2007 - is not started I get this error.
Regards,
Otto
PS: Privat:
Hallo Norbert,
ich habe über das Anfrageformular deiner Homepage vor einiger Zeit eine Anfrage gestellt. Hast du diese erhalten?
Gruß
Otto

Error occurred at: 03/09/08, 09:54:06
Error description: Error 2157156/0 S_OK: RECIPIENTS
Args:

Stack Calls
===========
Called from: => TOLEAUTO:RECIPIENTS(0)
Called from: test2007Email.prg => MAILSEND(145)
Called from: test2007Email.prg => (b)MAIN(37)

Posted: Sun Mar 09, 2008 6:09 pm
by NK
Otto wrote: PS: Privat:
Hallo Norbert,
ich habe über das Anfrageformular deiner Homepage vor einiger Zeit eine Anfrage gestellt. Hast du diese erhalten?
Sorry - nein. Schreib mir einfach eine Mail. Einfach auf die Taste "eMail"

Gruss, Norbert

Posted: Sun Mar 09, 2008 8:41 pm
by driessen
Otto,
Norbert,

I was able to solve the problem by using this code :

Code: Select all

oOutLook   := CreateObject("Outlook.Application")
oNameSpace := oOutlook:GetNameSpace("MAPI")
oMail  := oOutLook:CreateItem(olMailItem) 
oMail:Subject := ALLTRIM(EmOnde) 
oMail:Body    := ALLTRIM(FmText) 
oMail:Recipients:Add(cEmail[i]) 
oMail:CC  := TabCC 
oMail:BCC := TabBCC 
FOR j=1 TO LEN(TabBijl) 
    oMail:Attachments:Add(TabBijl[j]) 
NEXT 
oMail:HTMLBody := MEMOREAD(ALLTRIM(US->UOUTLSJAB)) 
oMail:Send()
I just added :

Code: Select all

oNameSpace := oOutlook:GetNameSpace("MAPI")
to my code.

Michel

Posted: Mon Mar 10, 2008 6:32 am
by Otto
Thanks Michael,
I tried the changes you suggested but the result is still the same.
Regards,
Otto

Posted: Mon Mar 10, 2008 8:04 am
by Otto
Hello Michael,
I found a solution for my problem:
If I use
oMail:To := "test@aon.at"
instead of:
oMail:Recipients:Add( "test@aon.at" )
all is working.

Regards,
Otto

Posted: Mon Mar 10, 2008 11:36 pm
by driessen
Otto,

But what happens in your solution when you have to send your email to several people ?

Michel

Posted: Tue Mar 11, 2008 8:58 am
by Otto
Michael, I successfully tried with a string like that: oMail:To := "test@aon.at;info@hotel.at;ruth@test.com;otto@aon.at"

Regards,
Otto

Posted: Tue Mar 11, 2008 4:55 pm
by driessen
Otto,

Thanks.

I'll try it out.

Michel

Outlook 2003 - A program is trying to send mail...

Posted: Fri Apr 18, 2008 3:27 pm
by David Williams
Michel

How did you get around this when using outlook 2003?

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

You can buy a solution called ClickYes Pro for $40 but they are looking for multiple user licences.

Do you know of a simpler way around this?

Regards
David

Posted: Fri Apr 18, 2008 3:49 pm
by Otto
I am not sure if this is the same problem I had but maybe you can try:

HKEY_CURRENT_USER\ Software\ Microsoft\ Office\ <VERSION>\ Word\ Options

einen neuen DWORD-Wert anlegen mit dem Namen SQLSecurityCheck, der Wert ist 0

VERSION = "10.0" für Word 2002, "11.0" für Word 2003 und "12.0" für Word 2007.

Regards,
Otto

Posted: Fri Apr 18, 2008 6:11 pm
by James Bott
David,

>How did you get around this when using outlook 2003?

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

With Outlook Express there is a setting under Options, Security that is:

"Warn me when other applications try to send mail as me."

Which you can turn off.

I expect that Outlook has the same setting somewhere.

James