Email through outlook

Post Reply
hag
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California
Contact:

Email through outlook

Post by hag »

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
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: Email through outlook

Post by Enrico Maria Giordano »

This is a working sample:

Code: Select all

#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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Email through outlook

Post by James Bott »

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
hag
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California
Contact:

Re: Email through outlook

Post by hag »

Thanks to both. Perfect.
Thank you
Harvey
User avatar
Sakis
Posts: 41
Joined: Fri Oct 21, 2005 2:12 pm
Location: Athens

Re: Email through outlook

Post by Sakis »

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
User avatar
Marco Turco
Posts: 858
Joined: Fri Oct 07, 2005 12:00 pm
Location: London
Contact:

Re: Email through outlook

Post by Marco Turco »

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
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: Email through outlook

Post by James Bott »

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
User avatar
Richard Chidiak
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France
Contact:

Email through outlook

Post by Richard Chidiak »

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
Post Reply