I have a VFP application which has inserted in it the helpful routine below, provided in this Forum by craigsboyd (Craig Boyd, thanks again !)
I tested the same application in 6 computers (all running Windows 98SE and with Outlook Express 6 SP1, and with the same directory name) and got the following result: in 4 of the computers the application works fine (it sends e-mail and an attachment to the Outlook Express Outbox), but in the other 2 computers the application doesn't send the e-mail to the Outlook Express Outbox and shows the customized error message, saying the e-mail cannot be sent ("Problem sending email!").
I did a lot of things in the 2 computers (the ones which I need the application to work) in which the routine doesn't work: reinstalled the Outlook Express 6, installed some update files downloaded from Microsoft, almost a hundred reinitialization in both machines during a whole week, but I haven't got the application to send e-mail !
How to make the Outlook Express to do this job ? How to know if a computer is ready for that application ?
Thanks,
Michel
---------------------------------------------------------
Routine provided by Craig Boyd (craigsboyd) in this forum
---------------------------------------------------------
*!* Sample Use of SendViaMAPI
DIMENSION aryAttachments(2)
aryAttachments(1) = "C:\test1.txt"
aryAttachments(2) = "C:\test2.txt"
IF SendViaMAPI("me@myhost.com", "someone@theirhost.com", "My Subject Line", "My Email Body", @aryAttachments)
MESSAGEBOX("Email sent successfully!")
ELSE
MESSAGEBOX("Problem sending email!")
ENDIF
****************************************************
FUNCTION SendViaMAPI(tcFrom, tcTo, tcSubject, tcBody, taFiles)
****************************************************
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
IF PCOUNT() > 4
FOR lnCountAttachments = 1 TO ALEN(taFiles)
.AttachmentIndex = .AttachmentCount
.AttachmentName = JUSTFNAME(taFiles(lnCountAttachments))
.AttachmentPosition = .AttachmentIndex
.AttachmentPathName = taFiles(lnCountAttachments)
ENDFOR
ENDIF
.SEND(.F.) && send in .T. to not send email automatically but instead see it in outlook
ENDWITH
loSession.Signoff()
STORE .NULL. to loSession, loMessages
RELEASE loSession, loMessages
RETURN .T.
ENDFUNC
I tested the same application in 6 computers (all running Windows 98SE and with Outlook Express 6 SP1, and with the same directory name) and got the following result: in 4 of the computers the application works fine (it sends e-mail and an attachment to the Outlook Express Outbox), but in the other 2 computers the application doesn't send the e-mail to the Outlook Express Outbox and shows the customized error message, saying the e-mail cannot be sent ("Problem sending email!").
I did a lot of things in the 2 computers (the ones which I need the application to work) in which the routine doesn't work: reinstalled the Outlook Express 6, installed some update files downloaded from Microsoft, almost a hundred reinitialization in both machines during a whole week, but I haven't got the application to send e-mail !
How to make the Outlook Express to do this job ? How to know if a computer is ready for that application ?
Thanks,
Michel
---------------------------------------------------------
Routine provided by Craig Boyd (craigsboyd) in this forum
---------------------------------------------------------
*!* Sample Use of SendViaMAPI
DIMENSION aryAttachments(2)
aryAttachments(1) = "C:\test1.txt"
aryAttachments(2) = "C:\test2.txt"
IF SendViaMAPI("me@myhost.com", "someone@theirhost.com", "My Subject Line", "My Email Body", @aryAttachments)
MESSAGEBOX("Email sent successfully!")
ELSE
MESSAGEBOX("Problem sending email!")
ENDIF
****************************************************
FUNCTION SendViaMAPI(tcFrom, tcTo, tcSubject, tcBody, taFiles)
****************************************************
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
IF PCOUNT() > 4
FOR lnCountAttachments = 1 TO ALEN(taFiles)
.AttachmentIndex = .AttachmentCount
.AttachmentName = JUSTFNAME(taFiles(lnCountAttachments))
.AttachmentPosition = .AttachmentIndex
.AttachmentPathName = taFiles(lnCountAttachments)
ENDFOR
ENDIF
.SEND(.F.) && send in .T. to not send email automatically but instead see it in outlook
ENDWITH
loSession.Signoff()
STORE .NULL. to loSession, loMessages
RELEASE loSession, loMessages
RETURN .T.
ENDFUNC