Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sending email within VFP
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
01160261
Message ID:
01160595
Views:
12
Are your SMTP server configured ?
I show you our class that is based in SendViaCDOSYS sample.
You can see how properties were setting
this.oMail = NEWOBJECT("sysSendMail","sysSendMail.prg")

this.oMail.lcFrom   = "Ing. Ricardo Fynn  <fynn@c-dev.net>"
this.oMail.lcSender = null && We had problems with some servers. Only with 'From' works fine.
lcMailTO = "ricardofynn@gmail.com"
this.oMail.lcSubject = "This is the mail subject"
this.oMail.llHTMLFormat = .T.
this.oMail.lcBody = "body text, can be HTML format"
this.oMail.lcCC         = "somepeople@yahoo.com"
this.oMail.lcBCC        = null   && carbon copy, not used in this sample
this.oMail.lcMailServer = "smtp.gmail.com"
this.oMail.lcUserName   = "ricardofynn"
this.oMail.lcPassword   = "myPwdHere"
this.oMail.lnPort       = 587  && more usual is port 25
this.oMail.laAttach[1]  = "C:\DOCS\myDocument.doc"

this.oMail.SendViaCDOSYS
Part of our class code (base in SendViaCDOSSYS) the method Send...
See that you must instance 2 objects, CDO.Confirguration and late CDO.Message
PROCEDURE SendViaCDOSYS AS void
LOCAL lcSchema, loAtt, lnCountAttachments
PRIVATE loConfig, loMsg
TRY
    lcSchema = "http://schemas.microsoft.com/cdo/configuration/"
    loConfig = CREATEOBJECT("CDO.Configuration")

    WITH loConfig.FIELDS
      .ITEM(lcschema + "smtpserverport")   = this.lnPort   && SMTP Port
      .ITEM(lcschema + "sendusing")        = 2             && Send it using port
    .  ITEM(lcschema + "smtpserver")       = this.lcMailServer && host of smtp server
      .ITEM(lcschema + "smtpauthenticate") = 1                 && Authenticate
      .ITEM(lcschema + "sendusername")     = this.lcUserName   && Username
      .ITEM(lcschema + "sendpassword")     = this.lcPassword   && Password
      .UPDATE
    ENDWITH

    loMsg = CREATEOBJECT ("CDO.Message")
    loMsg.configuration = loConfig
    WITH loMsg
        .FROM = this.lcFrom
        .TO   = this.lcTo
        IF TYPE("this.lcSender") = "C"
          .sender = this.lcSender
        ENDIF
        ... and so on
>Thanks, I've tryed this..
>
>
>oMSG = createobject("CDO.Message")
>oMSG.To = "jmartinez@plavicaven.com"
>oMSG.From = "jmartinez@plavicaven.com"
>oMSG.Subject = "automated email test"
>oMSG.AddAttachment("d:\myfile.txt")
>oMSG.Send()
>
>
>
>but it occurs an error on the last line (MSG.Send()), telling that the "SendUsing" configuration value is invalid.
>
>What am I doing wrong??
>
>
>>Jonathan,
>>
>>We found this to be a very fast and easy way to do email.
>>
>>http://fox.wikis.com/wc.dll?Wiki~CdoEmail~VFP
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform