PARAMETERS subjekt, telo, priloha1, priloha2, priloha3, kamvlastneposlat, filetelo, kopiakomu
IF EMPTY(m.telo)
	m.telo=m.subjekt
ENDIF 
LOCAL loConfig AS CDO.Configuration, loFlds AS Object, loMsg AS CDO.Message
*!*	m.uct_email_from="milan.barlok@alto.sk"
loConfig = CREATEOBJECT("CDO.Configuration")
loFlds = loConfig.Fields
WITH loFlds
	*- Set the CDOSYS configuration fields to use port 25 on the SMTP server.
	.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
	*- Enter name or IP address of remote SMTP server.
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = IIF(EMPTY(man_email_from),food_smtpserver, man_smtpserver)
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = IIF(EMPTY(man_email_from),food_smtpport, man_smtpport)
	*- Assign timeout in seconds
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = IIF(EMPTY(man_email_from),food_smtpssl, man_smtpssl)
	*- Commit changes to the object
	.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = IIF(EMPTY(man_email_from),food_smtpmeno, man_smtpmeno)
	.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = IIF(EMPTY(man_email_from),food_smtpheslo, man_smtpheslo)
	.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = IIF(EMPTY(man_email_from),food_smtpauth, man_smtpauth)           
	.Update()
ENDWITH
*- Create and send the message.
loMsg = CREATEOBJECT("CDO.Message")
TRY
  WITH loMsg
	.Configuration = loConfig
	.To = m.kamvlastneposlat
	.cc = IIF(EMPTY(m.kopiakomu),"",m.kopiakomu)
	.From = IIF(EMPTY(m.man_email_from),m.food_email_from, m.man_email_from)
	.Subject = m.subjekt
	.HTMLBody = m.telo
	IF !EMPTY(m.filetelo) AND FILE(m.filetelo)
		.HTMLBody=STRTRAN(FILETOSTR(m.filetelo),"charset=windows-1250","utf-8")
		.BodyPart.Charset = "windows-1250"
		.HTMLBodyPart.Charset = "windows-1250"
*!*			.MimeFormatted = .t.
*!*			strhtml= '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html>'
*!*			strhtml=strhtml+'<head><meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>Report Sushitime</title></head>'
*!*			strhtml=strhtml+'<body><img style="width: 794px; height: 1123px;" alt="Report" src=""cid:myimage.png""></body></html>'
*!*			.HTMLBody=strhtml

**		.HTMLBody = '<html>Check this out: <img src=""cid:myimage.png""></html>'
**		objBP = .AddRelatedBodyPart("file:///C:/tmp/fmilant530_fg/15050_555_1.png", "myimage.png", 1)		
**		objBP.Fields.Item("urn:schemas:mailheader:Content-ID") = "<myimage.png>"
**		objBP.Fields.Update


*!*			.HTMLBody = '<html>Check this out: <img src=""cid:myimage.gif""></html>'
*!*			objBP=.AddRelatedBodyPart("file://"+m.filetelo, "myimage.gif", 1)
*!*			objBP.Fields.Item("urn:schemas:mailheader:Content-ID") = "<myimage.gif>"
*!*			objBP.Fields.Update()
	ENDIF 
	IF !EMPTY(m.priloha1) AND FILE(m.priloha1)
		.AddAttachment(m.priloha1)
	ENDIF 
	IF !EMPTY(m.priloha2) AND FILE(m.priloha2)
		.AddAttachment(m.priloha2)
	ENDIF 
	IF !EMPTY(m.priloha3) AND FILE(m.priloha3)
		.AddAttachment(m.priloha3)
	ENDIF 
	.Send()
  ENDWITH 
CATCH TO oerr
    IF m.slovenskaverzia
        MESSAGEBOX(oerr.message)
	ELSE
        DO app_log WITH oerr.message
	ENDIF 
ENDTRY
