INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Automation

How to send e-mail using CDO and checking the connection status first. by mgagnon
Posted: 22 Mar 04 (Edited 8 Sep 08)

CODE

Local iMsg,iConf
Declare SHORT InternetGetConnectedState In wininet.Dll;
    INTEGER @lpdwFlags, Integer dwReserved
lConnect=displayState()
If lConnect
    iMsg = Createobject("CDO.Message")
    iConf = Createobject("CDO.Configuration")
    Flds = iConf.Fields
    With Flds
        .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = 'Your SMTP server name here'
        .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
        .Update()
    Endwith
    With iMsg
        .Configuration = iConf
        .To = "me@hotmail.com"
        .CC = ""
        .BCC = ""
        .From = "me@somewhere.com"
        .Subject = "This is a test"
        .Fields("Priority").Value = 1   && -1=Low, 0=Normal, 1=High
        .Fields.Update()
        .TextBody = "This is the body text"  && Plain text
      **.HTMLBody = "This is the HTML body text"  && Optional HTML message
        .AddAttachment( "C:/" + lcFilename) && Valid filename
        .Send()
    Endwith
    iMsg = .Null.
    iConf = .Null.
    Flds = .Null.
Else
    Messagebox("Could not send the message, you internet connection is down.")
Endif
Procedure  displayState
Local lConnected
lConnected = .F.
lpdwFlags = 0
If InternetGetConnectedState (@lpdwFlags, 0) = 1
    lConnected = .T.
Endif
Return lConnected
Endproc

Mike Gagnon
 

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close