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.
Email through outlook
Email through outlook
Thank you
Harvey
Harvey
- Enrico Maria Giordano
- Posts: 7355
- Joined: Thu Oct 06, 2005 8:17 pm
- Location: Roma - Italia
- Contact:
Re: Email through outlook
This is a working sample:
EMG
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
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Email through outlook
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
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
Re: Email through outlook
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
Enrico code work's only with XP. can anyone post the code for thw same task but on Vista.
Best Regards
Dionisis
- Marco Turco
- Posts: 858
- Joined: Fri Oct 07, 2005 12:00 pm
- Location: London
- Contact:
Re: Email through outlook
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
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
Marco Turco
SOFTWARE XP LLP
- James Bott
- Posts: 4654
- Joined: Fri Nov 18, 2005 4:52 pm
- Location: San Diego, California, USA
- Contact:
Re: Email through outlook
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
>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
- Richard Chidiak
- Posts: 946
- Joined: Thu Oct 06, 2005 7:05 pm
- Location: France
- Contact:
Email through outlook
Dionisis
Enrico's code work on Vista
Note : i use microsoft Outlook and it prompts the inbox
HTH
Richard
Enrico's code work on Vista
Note : i use microsoft Outlook and it prompts the inbox
HTH
Richard