FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Problem with OLE and Outlook 2007
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Problem with OLE and Outlook 2007
Posted: Fri Apr 20, 2007 01:09 PM
Hello,

I use this code to send email from my application :

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.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Problem with OLE and Outlook 2007
Posted: Fri Apr 20, 2007 01:16 PM

Probably a bug in Outlook 2007. Can't you just open Outlook using ShellExecute() before your sendmail code?

EMG

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Problem with OLE and Outlook 2007
Posted: Sat Mar 08, 2008 03:08 PM

Michel, how did you resolved the problem.

Thanks in advance
Otto

Posts: 97
Joined: Sun Nov 20, 2005 04:32 PM
Problem with OLE and Outlook 2007
Posted: Sat Mar 08, 2008 10:34 PM
Have you test this way ?

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


Regards, Norbert
Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Problem with OLE and Outlook 2007
Posted: Sun Mar 09, 2008 08:58 AM

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)

Posts: 97
Joined: Sun Nov 20, 2005 04:32 PM
Problem with OLE and Outlook 2007
Posted: Sun Mar 09, 2008 06:09 PM
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
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Problem with OLE and Outlook 2007
Posted: Sun Mar 09, 2008 08:41 PM
Otto,
Norbert,

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

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 :

oNameSpace := oOutlook:GetNameSpace("MAPI")


to my code.

Michel

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Problem with OLE and Outlook 2007
Posted: Mon Mar 10, 2008 06:32 AM

Thanks Michael,
I tried the changes you suggested but the result is still the same.
Regards,
Otto

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Problem with OLE and Outlook 2007
Posted: Mon Mar 10, 2008 08:04 AM

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

Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Problem with OLE and Outlook 2007
Posted: Mon Mar 10, 2008 11:36 PM

Otto,

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

Michel

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Problem with OLE and Outlook 2007
Posted: Tue Mar 11, 2008 08:58 AM

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

Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Problem with OLE and Outlook 2007
Posted: Tue Mar 11, 2008 04:55 PM

Otto,

Thanks.

I'll try it out.

Michel

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 82
Joined: Fri Mar 03, 2006 06:26 PM
Outlook 2003 - A program is trying to send mail...
Posted: Fri Apr 18, 2008 03:27 PM

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

Posts: 6983
Joined: Fri Oct 07, 2005 07:07 PM
Problem with OLE and Outlook 2007
Posted: Fri Apr 18, 2008 03:49 PM

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

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Problem with OLE and Outlook 2007
Posted: Fri Apr 18, 2008 06:11 PM

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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10