Email through outlook

Email through outlook

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

Re: Email through outlook

Postby Enrico Maria Giordano » Mon Sep 28, 2009 7:18 am

This is a working sample:

Code: Select all  Expand view
#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
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Email through outlook

Postby James Bott » Mon Sep 28, 2009 1: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Email through outlook

Postby hag » Mon Sep 28, 2009 7:14 pm

Thanks to both. Perfect.
Thank you
Harvey
hag
 
Posts: 598
Joined: Tue Apr 15, 2008 4:51 pm
Location: LOs Angeles, California

Re: Email through outlook

Postby Sakis » 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
User avatar
Sakis
 
Posts: 42
Joined: Fri Oct 21, 2005 2:12 pm
Location: Athens

Re: Email through outlook

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

Re: Email through outlook

Postby James Bott » Tue Oct 27, 2009 3: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Email through outlook

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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 40 guests