Página 1 de 1
Alguien tiene un ejemplo de como usar alguna libreria de chilkat
Publicado: Vie Jul 15, 2016 6:44 am
por Carlos Ortiz
Gracias
Re: Alguien tiene un ejemplo de como usar alguna libreria de chilkat
Publicado: Vie Ago 19, 2016 1:07 am
por Miguel Salas
METHOD BtnBmp1Click( oSender ) CLASS TFormSendMail
LOCAL loMailman
LOCAL lnSuccess
LOCAL loEmail
LOCAL cFileXml
LOCAL cFilePDF
local cCarpetaXML := appdata:cPath + "xml" + appdata:empresa
local cCarpetaPDF := appdata:cPath + "pdf" + appdata:empresa
local lcContentType
cFileXml := cCarpetaXML+"\"+AllTrim(::cserie) + "_" + AllTrim(::cFactura) + ".xml"
cFilePDF := cCarpetaPDF+"\"+AllTrim(::cserie) + "_" + AllTrim(::cFactura) + ".pdf"
//-------------------------------------------------------------------
* The mailman object is used for sending and receiving email.
loMailman := CreateObject('Chilkat_9_5_0.MailMan')
* Any string argument automatically begins the 30-day trial.
lnSuccess := loMailman:UnlockComponent("Aqui va tu licencia")
IF (lnSuccess <> 1)
MsgInfo( loMailman:LastErrorText)
RELEASE loMailman
RETURN NIL
ENDIF
WITH OBJECT loMailman
* Set the SMTP server.
:SmtpHost := ::oSqlQueryEmpresa:smtphost
* Set the SMTP login/password (if required)
:SmtpUsername := ::oSQLQueryEmpresa:smtpuser
:SmtpPassword := ::oSqlQueryEmpresa:smtppwd
:SmtpPort := ::oSqlQueryEmpresa:smtpport
END WITH
* Create a new email object
loEmail := CreateObject('Chilkat_9_5_0.Email')
WITH OBJECT loEmail
:Subject = ::oEdit2:Value
:Body = ::oEdit3:Value
:From = ::oDBEdit2:value
lnSuccess := :AddTo(Application:aForms[3]:oSqlTable1:nombre,::oEdit1:cText)
lcContentType := :AddFileAttachment(cFileXml)
IF (:LastMethodSuccess <> 1)
MsgBox( :LastErrorText)
RELEASE loEmail
CANCEL
ENDIF
lcContentType := :AddFileAttachment(cFilePDF)
IF (:LastMethodSuccess <> 1)
MsgBox( :LastErrorText)
RELEASE loEmail
CANCEL
ENDIF
* To add more recipients, call AddTo, AddCC, or AddBcc once per recipient.
* Call SendEmail to connect to the SMTP server and send.
* The connection (i.e. session) to the SMTP server remains
* open so that subsequent SendEmail calls may use the
* same connection.
END WITH
lnSuccess := loMailman:SendEmail(loEmail)
IF (lnSuccess <> 1)
MsgInfo( loMailman:LastErrorText)
RELEASE loMailman
RELEASE loEmail
RETURN NIL
ENDIF
* Some SMTP servers do not actually send the email until
* the connection is closed. In these cases, it is necessary to
* call CloseSmtpConnection for the mail to be sent.
* Most SMTP servers send the email immediately, and it is
* not required to close the connection. We'll close it here
* for the example:
lnSuccess := loMailman:CloseSmtpConnection()
IF (lnSuccess <> 1)
MsgInfo( "La Connexion con el servidor SMTP no fue cerrada correctamente.")
ENDIF
MsgInfo( "Factura enviada exitosamente!")
RELEASE loMailman
RELEASE loEmail
RETURN Nil
Re: Alguien tiene un ejemplo de como usar alguna libreria de chilkat
Publicado: Sab Ago 20, 2016 11:15 pm
por Carlos Ortiz
Gracias colega, lo pruebo y te cuento (ando renegando con los ftp espero poder resolverlo)
Saludos desde Argentina
Re: Alguien tiene un ejemplo de como usar alguna libreria de chilkat
Publicado: Mié Ago 24, 2016 3:50 am
por Miguel Salas
muy buena lib, suerte