Problem with OLE and Outlook 2007

User avatar
driessen
Posts: 1239
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Post by driessen »

Hello guys,

There is a much easier solution to get arround this problem with Outlook.

You can download it free at : www.mapilab.com/outlook/security

It works with all Outlook versions.

Regards,
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Wanderson
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Re: Problem with OLE and Outlook 2007

Post by Wanderson »

Hi, anyone have a solution about this error?

I have try:

oOutLook := CreateObject("Outlook.Application")
oNameSpace := oOutlook:GetNameSpace("MAPI")
oMail := oOutLook:CreateItem(0)
oMail:Subject := "test"
oMail:Body := "test"
oMail:Recipients:Add("myemail")
oMail:CC := ""
oMail:BCC := ""
oMail:Send()

and:

oOutLook := CreateObject("Outlook.Application")
oNameSpace := oOutlook:GetNameSpace("MAPI")
oMail := oOutLook:CreateItem(0)
oMail:Subject := "test"
oMail:Body := "test"
oMail:To := "myemail"
oMail:CC := ""
oMail:BCC := ""
oMail:Send()

and both gives the error: Error description: Error Outlook.Application:CREATEITEM/0 S_OK: RECIPIENTS

If i open outlook 2007 first thats ok. Any idea? Thanks in advance.

Wanderson
User avatar
driessen
Posts: 1239
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Problem with OLE and Outlook 2007

Post by driessen »

Hello,

I use exactly the same code without having any problems.

But I noticed the you use

Code: Select all

oMail:Recipients:Add("myemail")
Maybe you should try a real e-mail address with a @ in it.

Good luck.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Wanderson
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Re: Problem with OLE and Outlook 2007

Post by Wanderson »

driessen wrote:Hello,

I use exactly the same code without having any problems.

But I noticed the you use

Code: Select all

oMail:Recipients:Add("myemail")
Maybe you should try a real e-mail address with a @ in it.

Good luck.
Hello driessen, "myemail" its just a exemple i have using a real email in this case, but if outlook2007 is not open show the error reported, what your fwh version?

Thanks in advance.
User avatar
driessen
Posts: 1239
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Problem with OLE and Outlook 2007

Post by driessen »

Hello,

Sorry but I think I didn't understand your question very well.

This is the code I use to make a connection to Outlook to avoid the error you mentioned :

Code: Select all

LOCAL cTasks

LOCAL OutlFound := .F.

cTasks := GetTasks()
FOR i=1 TO LEN(cTasks)
    IF AT("OUTLOOK",UPPER(cTasks[i])) <> 0
       OutlFound := .T.
       i := LEN(cTasks)
    ENDIF
NEXT
IF !OutlFound ; ShellExecute(,"Open","Outlook",,,3) ; ENDIF

TRY
   oOutLook   := CreateObject("Outlook.Application")
   oNameSpace := oOutlook:GetNameSpace("MAPI")
   EmSend     := .T.
CATCH
   TRY
      oOutLook   := CreateObject("Outlook.Application")
      oNameSpace := oOutlook:GetNameSpace("MAPI")
      EmSend     := .T.
   CATCH
      EmSend   := .F.
   END
END

IF EmSend

    // Your source to send your mail

ENDIF
 
Hope this can help you. It runs fine in my application.

Good luck.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 21.01 - Harbour 3.2.0 (October 2020) - xHarbour Builder (January 2020) - Bcc7
Post Reply