
#pragma library( "ascom10.lib" )
Procedure Main()
LOCAL  oConfig, oMessage

//
//   Parâmetros para "CDO.Configure"
            //  CDO.sendUsing
     LOCAL  cdoSendUsingPickup         :=  1       // Send the message by using the local SMTP service pickup directory.
     LOCAL  cdoSendUsingPort           :=  2       // Send the message by using the network (SMTP over the network).
     LOCAL  cdoSendUsingExchange       :=  3       // Send the message by using the Microsoft Exchange mail submission
                                                      // Uniform Resource Identifier (URI). This URI is found in the user's
                                                      // urn:schemas:httpmail:sendmsg mailbox folder property.
            //  CDO.smtpServer
     LOCAL  smtpServer                 := 'smtp.bipbip.com.br'
     LOCAL  smtpUseSsl                 := .t.      // A boolean value indicating that Secure Sockets Layer (SSL) must
                                                      // be used when posting messages
     LOCAL  smtpNotUseSsl              := .f.      // A boolean value indicating that Secure Sockets Layer (SSL) should not
                                                      // be used when posting messages over the network using the SMTP protocol.
     LOCAL  smtpSerVerPort             := 587
     LOCAL  smtpconnectiontimeout      := 60
            //  CDO.authenticate
     LOCAL  cdoAnonymous               := 0        // não autentica
     LOCAL  cdoBasic                   := 1        // autenticação básica
     LOCAL  cdoNTLM                    := 2        // exige username e password
//
//   Parâmetros para "CDO.message"
            //  CDO:DNSOptions:
     LOCAL  cdoDSNDefault              :=  0       // No delivery status notifications are issued.
     LOCAL  cdoDSNNever                :=  1       // No delivery status notifications are issued.
     LOCAL  cdoDSNFailure              :=  2       // Returns a delivery status notification if delivery fails.
     LOCAL  cdoDSNSuccess              :=  4       // Returns a delivery status notification if delivery succeeds.
     LOCAL  cdoDSNDelay                :=  8       // Returns a delivery status notification if delivery is delayed.
     LOCAL  cdoDSNSuccessFailOrDelay   := 14       // Returns a delivery status notification if delivery succeeds, fails, or is delayed.

                  //
                  //    Configuring the remote SMTP Server
oConfig    := CreateObject("CDO.Configuration")  //  (Docs.: http://msdn.microsoft.com/en-us/library/ms526318(v=exchg.10).aspx)
if oConfig == NIL
   MsgBox('Could not create object CDO.Message', 'Unexpected Error')
   quit
endif

oConfig:sendUsing             := cdoSendUsingPort
oConfig:sendUserName          := 'smtp.bipbip.com.br'
oConfig:sendPassword          := 'Lmopb01'
oConfig:smtpServer            := smtpServer
oConfig:smtpserverport        := smtpServerPort
oConfig:smtpusessl            := smtpUseSsl
oConfig:authenticate          := cdoNTLM
oConfig:smtpconnectiontimeout := smtpconnectiontimeout
oConfig:update()
                  //
                  //    Cria a mensagem
oMessage := CreateObject("CDO.Message")
if oMessage == NIL
   MsgBox('Could not create object CDO.Message', 'Unexpected Error')
   quit
endif


oMessage:configuration  := oConfig

   //Connection Timeout in seconds (the maximum time CDO will try to establish a connection to the SMTP server)
oMessage:configuration:cdosmtpconnectiontimeout := 60
oMessage:Configuration:Fields:Update()


oMessage:Subject       := "Example CDO Message"
oMessage:setProperty('From', "tassobr@aol.com")    // "From" é palavra reservada
oMessage:bcc           := "tassobr@aol.com"   // May be to, cc, bcc
oMessage:TextBody      := "This is some sample message text."
oMessage:AddAttachment((CurDrive() + ':\' + CurDir() + '\Test1.prg'))
oMessage:DNSOptions    := cdoDSNNever
oMessage:Send()
RETURN


/*
 *
 *    Documentation
 *

set objMsg = CreateObject("CDO.Message")
set objConf = CreateObject("CDO.Configuration")

Set objFlds = objConf.Fields
With objFlds
  .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
  .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.yourhost.com"
  .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasic
  .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "your-username"
  .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "your-password"
  .Update
End With

strBody = "This is a sample message." & vbCRLF
strBody = strBody & "It was sent using CDO." & vbCRLF

With objMsg
  Set .Configuration = objConf
  .To = "test@paulsadowski.com"
  .From = "me@my.com"
  .Subject = "This is a CDO test message"
  .TextBody = strBody
   'use .HTMLBody to send HTML email.
  .Addattachment "c:\temp\Scripty.zip"
  .Fields("urn:schemas:mailheader:disposition-notification-to") = "me@my.com"
  .Fields("urn:schemas:mailheader:return-receipt-to") = "me@my.com"
  .DSNOptions = cdoDSNSuccessFailOrDelay
  .Fields.update
  .Send
End With

 */