FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Email through outlook
Posts: 598
Joined: Tue Apr 15, 2008 04:51 PM
Email through outlook
Posted: Sun Sep 27, 2009 11:40 PM

Hello all:

I would like to email some information directly from my app. However I would like the program to open outlook and have the subject automatically appear on subject line and a link placed into the text.
I have some code now it automatically mails me error log messages. But it doesnt open the email so the user can add some comments.
Suggestions and code please. Thanks in advance.

Thank you

Harvey
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Email through outlook
Posted: Mon Sep 28, 2009 07:18 AM
This is a working sample:

Code (fw): Select all Collapse
#include "Fivewin.ch"


FUNCTION MAIN()

    SHELLEXECUTE( 0, 0, "mailto:e.m.giordano@emagsoftware.it?subject=This is a test&body=www.emagsoftware.it", 0, 0, 1 )

    RETURN NIL


EMG
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Email through outlook
Posted: Mon Sep 28, 2009 01:32 PM

Harvey,

Enrico's solution will work, or if you are using the DEFINE MAIL syntax just add FROM USER to get the new message dialog to appear.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 598
Joined: Tue Apr 15, 2008 04:51 PM
Re: Email through outlook
Posted: Mon Sep 28, 2009 07:14 PM

Thanks to both. Perfect.

Thank you

Harvey
Posts: 42
Joined: Fri Oct 21, 2005 02:12 PM
Re: Email through outlook
Posted: Tue Oct 27, 2009 12:33 PM

Hello to all

Enrico code work's only with XP. can anyone post the code for thw same task but on Vista.

Best Regards
Dionisis

Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Re: Email through outlook
Posted: Tue Oct 27, 2009 12:40 PM
Hi,
this routine will use Outlook via OLE if available otherwise the default mail client.


#include "FiveWin.ch"
#include "Mail.ch"

FUNCTION Interactivemessage()
paramet cSubject, cBody, aTo, aFiles, lDirectSend,lUseCC

LOCAL oOutLook,oMailItem,oRecip,oAttach,i,lOffice,lMailMancante,cVar
local nSelected,oDlg1

if lUseCC=NIL
lUseCC:=.f.
endif

if lDirectSend=NIL
lDirectSend:=.f.
endif

if cSubject=NIL
cSubject:=""
endif
if cBody=NIL
cBody:=""
endif
if aFiles=NIL
aFiles:=array(0,0)
endif

lMailMancante:=.f.
for i:=1 to len(aTo)
if len(alltrim(aTo[i,2]))=0
lMailMancante:=.t.
endif
next

if lMailMancante
MsgStop("Indirizzo di posta elettronica assente","Attenzione")
return
endif

lOffice:=.t.
TRY
oOutLook := CreateObject( "Outlook.Application" )
oMailItem := oOutLook:CreateItem( 0 )
oRecip := oMailItem:Recipients
CATCH
lOffice:=.f.
END

****

if lOffice
if lUseCC
cVar:=""
for i:=1 to len(aTo)
cVar:=cVar+aTo[i,2]+";"
next
oMailItem:Bcc:=cVar
else
for i:=1 to len(aTo)
oRecip:Add( aTo[i,2] )
next
endif

oMailItem:Subject := cSubject

oMailItem:Body := cBody

if len(aFiles)>0
oAttach := oMailItem:Attachments
for i:=1 to len(aFiles)
oAttach:Add( aFiles[i,1] )
next
endif

if lDirectSend
oMailItem:Send()
else
oMailItem:display(.t.)
endif
else
for i:=1 to len(aTo)
aTo[i,1]:=alltrim(aTo[i,2])
aTo[i,2]:=alltrim(aTo[i,2])
next


oMail:=tMail():New( cSubject,cBody,,,,, .f., .t.,,aTo,aFiles)

ACTIVATE MAIL oMail
retcode:=oMail:nRetCode

do case
case retcode=1
MsgStop("Invio interrotto dall'utente","Errore")
case retcode=9
MsgStop("Troppi files da inviare","Errore")
case retcode>0
MsgStop("Errore nell'invio della mail ("+alltrim(str(retcode,3))+")","Errore")
endcase
endif
return
Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Email through outlook
Posted: Tue Oct 27, 2009 03:24 PM

Dionisis,

>Enrico code work's only with XP. can anyone post the code for thw same task but on Vista.

Have you tried:

DEFINE MAIL...

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 946
Joined: Thu Oct 06, 2005 07:05 PM
Email through outlook
Posted: Thu Oct 29, 2009 09:18 AM

Dionisis

Enrico's code work on Vista

Note : i use microsoft Outlook and it prompts the inbox

HTH

Richard

http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013

Continue the discussion