Problem with OLE and Outlook 2007

Problem with OLE and Outlook 2007

Postby driessen » Fri Apr 20, 2007 1:09 pm

Hello,

I use this code to send email from my application :

Code: Select all  Expand view
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. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1399
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Problem with OLE and Outlook 2007

Postby Enrico Maria Giordano » Fri Apr 20, 2007 1:16 pm

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

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8356
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Otto » Sat Mar 08, 2008 3:08 pm

Michel, how did you resolved the problem.

Thanks in advance
Otto
User avatar
Otto
 
Posts: 6045
Joined: Fri Oct 07, 2005 7:07 pm

Postby NK » Sat Mar 08, 2008 10:34 pm

Have you test this way ?

Code: Select all  Expand view
      oOutLook := CreateObject( "Outlook.Application" )
      oMail := oOutLook:CreateItem( 0 )
      oRecip := oMail:Recipients
      oRecip:Add( AllTrim( cTo ) )


Regards, Norbert
User avatar
NK
 
Posts: 97
Joined: Sun Nov 20, 2005 4:32 pm
Location: Germany

Postby Otto » Sun Mar 09, 2008 8: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)
User avatar
Otto
 
Posts: 6045
Joined: Fri Oct 07, 2005 7:07 pm

Postby NK » Sun Mar 09, 2008 6: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
User avatar
NK
 
Posts: 97
Joined: Sun Nov 20, 2005 4:32 pm
Location: Germany

Postby driessen » Sun Mar 09, 2008 8:41 pm

Otto,
Norbert,

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

Code: Select all  Expand view
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  Expand view
oNameSpace := oOutlook:GetNameSpace("MAPI")


to my code.

Michel
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1399
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Otto » Mon Mar 10, 2008 6:32 am

Thanks Michael,
I tried the changes you suggested but the result is still the same.
Regards,
Otto
User avatar
Otto
 
Posts: 6045
Joined: Fri Oct 07, 2005 7:07 pm

Postby Otto » Mon Mar 10, 2008 8: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
User avatar
Otto
 
Posts: 6045
Joined: Fri Oct 07, 2005 7:07 pm

Postby driessen » 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. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1399
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Postby Otto » Tue Mar 11, 2008 8: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
User avatar
Otto
 
Posts: 6045
Joined: Fri Oct 07, 2005 7:07 pm

Postby driessen » Tue Mar 11, 2008 4:55 pm

Otto,

Thanks.

I'll try it out.

Michel
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1399
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

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

Postby David Williams » Fri Apr 18, 2008 3: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
User avatar
David Williams
 
Posts: 82
Joined: Fri Mar 03, 2006 6:26 pm
Location: Ireland

Postby Otto » Fri Apr 18, 2008 3: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
User avatar
Otto
 
Posts: 6045
Joined: Fri Oct 07, 2005 7:07 pm

Postby James Bott » Fri Apr 18, 2008 6: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 27 guests