procedure mailsend(recipname,subject,msgnote,attachs)
local lcschema, loconfig, lomsg, loerror, lcerror, lnfiles
store 0 to lnfiles
store '' to lcerror
lcschema = 'http://schemas.microsoft.com/cdo/configuration/'
try
wait(' Enviando, Gmail ',1,48)
loconfig = createobject('cdo.configuration')
with loconfig.fields
.item(lcSchema + "smtpserver") = "smtp.gmail.com"
.item(lcSchema + "smtpserverport") = 465
.item(lcSchema + "sendusing") = 2
.item(lcSchema + "smtpauthenticate") = .T.
.item(lcSchema + "smtpusessl") = .T.
.item(lcSchema + "sendusername") = 'aqui tu correo gmail'
.item(lcSchema + "sendpassword") = 'aqui tu contraseña'
.update
endwith
if !empty(attachs)
lnfiles = adir(lcfiles,attachs)
attachs = substr(attachs,1,len(alltrim(attachs))-(len(justfname(attachs))))
endif
lomsg = createobject('cdo.message')
with lomsg
.configuration = loconfig
.from = 'aqui correo origen'
.to = recipname
.Subject = subject
.TextBody = msgnote
if lnfiles # 0
for i = 1 to lnfiles
.addattachment(attachs+lcfiles(i,1))
next
endif
.send()
endwith
catch to loerror
lcerror = [Error: ] + str(loerror.errorno) + chr(13)+ ;
[Linea: ] + str(loerror.lineno) + chr(13)+ ;
[Mensaje: ] + loerror.message
finally
release loconfig, lomsg, lcfiles
store .null. to loconfig, lomsg
if !empty(lcerror)
wait(lcerror,3,16)
endif
endtry
return .t.