Luis Maria Guayan

01/07/2004 - 01:08 por luis suescun | Informe spam
Hola Luis Maria...

Felicitaciones Hombre... me parece excelente la aplicacion de administracion
de correo desde vfp.

Una pregunta: tienes alguna herramienta que trabaje mapi puro, que no se
tenga que tener outlook instalado.
o donde la consigo.

Gracias

Preguntas similare

Leer las respuestas

#1 Mauricio Henao
27/07/2004 - 17:44 | Informe spam
Hola Luis.

Veras, hay muchas herramientas que te permitiran hacer
envio de Email desde VFP, puedes hacerlo por medio de
MAPI, OUTLOOK, CDONTS, CDOSYS, y JMAIL.

Mira este ejemplo (salido de Tek).

DIMENSION aryAttach(1)
LOCAL lcFrom, lcTo, lcSubject, lcBody, lnCount
aryAttach(1) = "C:\autoexec.bat"
lcFrom = ""
lcTo = ""
lcSubject = "Hey Have You Tried VFP Email?"
lcBody = "Just wanted to let you know that VFP is pretty
versatile and has a lot of ways to send email."

FOR lnCount = 1 TO 5 &&let's do them all, some will work
some may not
=SendEmail(lnCount, lcFrom, lcTo, lcSubject, lcBody,
@aryAttach)
ENDFOR


PROCEDURE SendEmail(tcType, tcFrom, tcTo, tcSubject,
tcBody, tcFiles)
LOCAL llEmailStatus, lcErrorHandlerWas, lcType
lcErrorHandlerWas = ON("ERROR")
lcType = ""
WAIT WINDOW " One Moment... Email is being
generated and sent " NOWAIT
DO CASE
CASE tcType = 1
llEmailStatus = SendViaMAPI(tcFrom, tcTo,
tcSubject, tcBody)
lcType = "MAPI"
CASE tcType = 2
llEmailStatus = SendViaOutlook(tcFrom, tcTo,
tcSubject, tcBody, @tcFiles)
lcType = "OUTLOOK"
CASE tcType = 3
llEmailStatus = SendViaCDOnts(tcFrom, tcTo,
tcSubject, tcBody, @tcFiles)
lcType = "CDONTS"
CASE tcType = 4
llEmailStatus = SendViaCDOsys(tcFrom, tcTo,
tcSubject, tcBody, @tcFiles)
lcType = "CDOSYS"
CASE tcType = 5
llEmailStatus = SendViaJMail(tcFrom, tcTo,
tcSubject, tcBody, @tcFiles)
lcType = "JMAIL"
ENDCASE
IF !EMPTY(lcErrorHandlerWas)
ON ERROR &lcErrorHandlerWas
ELSE
ON ERROR
ENDIF
WAIT CLEAR
IF llEmailStatus
MESSAGEBOX("Your message to " + tcTo + " has been
sent.",64,"EMAIL SENT SUCCESSFULLY VIA " + lcType)
ELSE
MESSAGEBOX("Your message to " + tcTo + " was not
sent.",64,"EMAIL PROBLEM WITH " + lcType)
ENDIF
ENDPROC

FUNCTION SendViaMAPI(tcFrom, tcTo, tcSubject, tcBody)
ON ERROR RETURN(.F.)
LOCAL loSession, loMessages
loSession = CREATEOBJECT( "MSMAPI.MAPISession" )
loSession.Signon()
IF (loSession.SessionID > 0)
loMessages = CREATEOBJECT( "MSMAPI.MAPIMessages" )
loMessages.SessionID = loSession.SessionID
ENDIF
WITH loMessages
.Compose()
.RecipDisplayName = tcTo
.RecipType = 1
.ResolveName()
.MsgSubject = tcSubject
.MsgNoteText = tcBody
.SEND(.F.)
ENDWITH
loSession.Signoff()
STORE .NULL. to loSession, loMessages
RELEASE loSession, loMessages
RETURN .T.
ENDFUNC


FUNCTION SendViaOutlook(tcFrom, tcTo, tcSubject, tcBody,
tcFiles)
ON ERROR RETURN(.F.)
LOCAL oOutlook, oItem, lnCountAttachments
oOutlook = CREATEOBJECT("outlook.application")
oItem = oOutlook.CreateItem(0)
WITH oItem
.Subject = tcSubject
.TO = tcTo
.Body = tcBody
IF PCOUNT() > 4
FOR lnCountAttachments = 1 TO ALEN(tcFiles)
.Attachments.ADD(tcFiles
(lnCountAttachments))
ENDFOR
ENDIF
.SEND
ENDWITH
STORE .NULL. to oOutlook, oItem
RELEASE oOutlook, oItem
RETURN .T.
ENDFUNC


FUNCTION SendViaCDOnts(tcFrom, tcTo, tcSubject, tcBody,
tcFiles)
ON ERROR RETURN(.F.)
LOCAL oNewMail, lnCountAttachments
oNewMail = CREATEOBJECT("CDONTS.NewMail")
WITH oNewMail
.FROM = tcFrom
.TO = tcTo
.Subject = tcSubject
.Body = tcBody
IF PCOUNT() > 4
FOR lnCountAttachments = 1 TO ALEN(tcFiles)
.AttachFile = tcFiles(lnCountAttachments)
ENDFOR
ENDIF
.SEND
ENDWITH
oNewMail = .NULL.
RELEASE oNewMail
RETURN .T.
ENDFUNC

FUNCTION SendViaCDOsys(tcFrom, tcTo, tcSubject, tcBody,
tcFiles)
ON ERROR RETURN(.F.)
Local lcSchema, loConfig, loMsg, loAtt,
lnCountAttachments
lcSchema
= "http://schemas.microsoft.com/cdo/co...ion/"

loConfig = CREATEOBJECT("CDO.Configuration")

WITH loConfig.FIELDS
.ITEM(lcSchema + "smtpserverport") = 25 && SMTP
Port
.ITEM(lcSchema + "sendusing") = 2 && Send it using
port
.ITEM(lcSchema + "smtpserver") = "mail.myhost.com"
&& host of smtp server
.ITEM(lcSchema + "smtpauthenticate") = 1 &&
Authenticate
.ITEM(lcSchema + "sendusername") = "VaLiDUserNaMe"
&& Username
.ITEM(lcSchema + "sendpassword") = "PaSsWoRd1234"
&& Password
.UPDATE
ENDWITH

loMsg = CREATEOBJECT ("CDO.Message")
loMsg.Configuration = loConfig
WITH loMsg
.TO = tcTo
.From = tcFrom
.Subject = tcSubject
.TextBody = tcBody
IF PCOUNT() > 4
FOR lnCountAttachments = 1 TO ALEN(tcFiles)
loAtt=.AddAttachMent(tcFiles
(lnCountAttachments))
ENDFOR
ENDIF
.SEND()
ENDWITH

STORE .NULL. to loConfig, loMsg
RELEASE loConfig, loMsg
RETURN .T.
ENDFUNC

FUNCTION SendViaJMail(tcFrom, tcTo, tcSubject, tcBody,
tcFiles)
ON ERROR RETURN(.F.)
***Requires FREEWARE w3 JMail Free, v 4.3
***Download at http://tech.dimac.net/
LOCAL oSMTPMail, lnCountAttachments
oSMTPMail = CREATEOBJECT("jmail.SMTPMail")
*!* oSMTPMail .ServerAddress = "mail.domain.com"
WITH oSMTPMail
.AddRecipient(tcTo)
.Sender = tcFrom
.SenderName = tcFrom
.Subject = tcSubject
.Body = tcBody
IF PCOUNT() > 4
FOR lnCountAttachments = 1 TO ALEN(tcFiles)
.AddAttachMent(tcFiles(lnCountAttachments))
ENDFOR
ENDIF
.Execute()
ENDWITH
oSMTPMail = .NULL.
RELEASE oSMTPMail
RETURN .T.
ENDFUNC



Claro, tambien puedes visitar http://www.ostrosoft.com/,
alli hay una serie de herramientas FREEWARE para trabajar
con VB, pero puedes adecuarlas a VFP.
Necesitaras hacer download a la libreria ossmtp.dll y
luego crear el PRG.
Recuerda registrarla en la carpeta de tu sistema.
Windows\system
WinNt\system32



lcServer = "192.168.1.22"
lnPort = 25
lcAuthType = 0

oSmtp = CREATEOBJECT("OSSMTP.SMTPSession")

oSmtp.Server = lcServer
oSmtp.Port = lnPort


oSmtp.MailFrom=lcFrom
oSmtp.SendTo = lcTo
*oSmtp.BCC = lcBCC
*oSmtp.CC = lcCC

oSmtp.MessageSubject = lcSubject

oSmtp.MessageText = lcBody
*oSmtp.MessageHTML = (FILETOSTR("htmlsample.txt"))
oSmtp.Attachments.Add(lcAttachment)

oSmtp.AuthenticationType=0

oSmtp.SendEmail


RETURN oSmtp.Status
RELEASE oSmtp


*!* Methods:
*!* oSmtp.SendEmail()
*!* connects to server, authenticates (if requested),
sends message, closes the connection

*!* Properties:
*!* oSmtp.AuthenticationType

*!* Returns/Sets authentication type (default - 0)
*!* supported types are: POP3(1), AUTH LOGIN (2), AUTH
PLAIN(3)

*!* oSmtp.BCC
*!* Returns/Sets BCC e-mail address

*!* oSmtp.CC
*!* Returns/Sets CC e-mail address

*!* oSmtp.Charset
*!* Returns/Sets message charset (default - "us-ascii")

*!* oSmtp.MailFrom
*!* Returns/Sets sender e-mail address

*!* oSmtp.MessageHTML
*!* Returns/Sets HTML part of message (optional)

*!* oSmtp.MessageSubject
*!* Returns/Sets subject of message

*!* oSmtp.MessageText
*!* Returns/Sets text of message

*!* oSmtp.Password
*!* Returns/Sets password for server authentication
(optional)

*!* oSmtp.POPServer
*!* Returns/Sets server for POP3 authentication
(optional)

*!* oSmtp.Port
*!* Returns/Sets object server port (default - 25)

*!* oSmtp.SendTo
*!* Returns/Sets recipient e-mail address

*!* oSmtp.Server
*!* Returns/Sets object server name or IP address

*!* oSmtp.Status
*!* Returns status of component

*!* oSmtp.TimeStamp
*!* Returns/Sets message timestamp (default - system
date/time)

*!* oSmtp.Username
*!* Returns/Sets username for server authentication
(optional)




Hola Luis Maria...

Felicitaciones Hombre... me parece excelente la


aplicacion de administracion
de correo desde vfp.

Una pregunta: tienes alguna herramienta que trabaje mapi


puro, que no se
tenga que tener outlook instalado.
o donde la consigo.

Gracias


.

email Siga el debate Respuesta Responder a este mensaje
Ads by Google
Help Hacer una preguntaRespuesta Tengo una respuesta
Search Busqueda sugerida