Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cdo sample
Message
 
To
29/10/2004 09:17:47
General information
Forum:
Visual FoxPro
Category:
Internet applications
Title:
Miscellaneous
Thread ID:
00955172
Message ID:
00955755
Views:
18
Rick means something that is purchased like his wwsmtp tool. I have to admit that there probably is a little more setup and possibility of configuration issues with CDO or CDONTS, but, that's the price you pay for "free" as far as smtp e-mail is concerned. Once set up, though, CDO is pretty good for most purposes...

>>>Hello,
>>>I need a vfp sample code that can send a mail with cdo.
>>>But i want to set the smtpserver, username, password setting self.
>>>I dont want to use the settings from outlook or outlook express.
>>>Thanks.
>>
>>I'm not a big fan of CDO because of installation and configuration issues for client installations. But here's some code that works with CDO:
>>
>>
>>* Sends mail via SMTP
>>FUNCTION CDOMail
>>LPARAMETERS lcMailServer, lcSenderEmail, lcRecipient, lcSubject, lcMessage,lcUsername,lcPassword
>>
>>LOCAL iMsg as CDO.Message
>>iMsg = CreateObject("CDO.Message")
>>
>>LOCAL iConf as CDO.Configuration
>>iConf = CreateObject("CDO.Configuration")
>>
>>Flds = iConf.Fields
>>
>>Flds.Item("http://schemas.microsoft.com/cdo/configuration/cdoSendUsingMethod")=2
>>Flds.Item("http://schemas.microsoft.com/cdo/configuration/cdoSendUsingMethod/cdoSMTPServer")= lcMailServer
>>Flds.Item("http://schemas.microsoft.com/cdo/configuration/cdoSendUsingMethod/cdoSMTPServerPort")=25
>>
>>IF !EMPTY(lcUserName)
>>   Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword")=lcPassword
>>   Flds.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword")=lcUsername
>>ENDIF
>>
>>Flds.Item("urn:schemas:mailheader:content-type")="text/html"
>>
>>Flds.Update
>>
>>With iMsg
>>     .Configuration = iConf
>>     .To          = lcRecipient
>>     .From        = lcSenderEmail
>>     .Sender      = lcSenderEmail
>>     .Subject     = lcSubject
>>     .TextBody    = lcMessage
>>
>>     *iBp =  .AddAttachment("d:\temp\home.htm")
>>     *iBp.ContentMediaType="text/html"
>>
>>     TRY
>>        .Send()
>>     CATCH TO loException
>>         lcError = loException.aErrors[3]
>>         IF ISNULL(lcError) OR lcError = ""
>>            lcError = MESSAGE()
>>         ENDIF
>>     ENDTRY
>>ENDWITH
>>
>>RETURN ""
>>
>>
>>A more robust and machine configuration independent way to do this is to use a raw SMTP component.
>
>Thank you for this code.
>What do you mean with SMTP Component?
>Thanks.
Previous
Reply
Map
View

Click here to load this message in the networking platform