Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error send E-mail CDO Object

Status
Not open for further replies.

Rob1412

Programmer
Sep 10, 2003
9
0
0
VE
Need help here...
I got this code from another thread i would apreciate anybody giving a hand

When I set the variable cdoSendUsingPort = 25 as indicated in the original trhread i get an error message "Error 3749 Fields Update Failed. For further information , examine the Status property of individual field objects."
on the line where the Update is executed.

The curious thing is if i use port such as cdoSendUsingPort =2 i get an error where the Send command is executed which states something like "Server response not available".

Could someone enlighten me ????


Dim iMsg
Dim iConf
Dim Flds
Dim strHTML

Const cdoSendUsingPort = 2

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

Set Flds = iConf.Fields

' Set the CDOSYS configuration fields to use port 25 on the SMTP server.

With Flds

.Item(" = cdoSendUsingPort
'ToDo: Enter name or IP address of remote SMTP server.
.Item(" = "Server"
.Item(" = 10
.Update
End With

' Build HTML for message body.
strHTML = "<HTML>"
strHTML = strHTML & "<HEAD>"
strHTML = strHTML & "<BODY>"
strHTML = strHTML & "<b> This is the test HTML message body</b></br>"
strHTML = strHTML & "</BODY>"
strHTML = strHTML & "</HTML>"

' Apply the settings to the message.
With iMsg
Set .Configuration = iConf
.To = "test@test.com" 'ToDo: Enter a valid email address.
.From = "test@test.com" 'ToDo: Enter a valid email address.
.Subject = "This is a test CDOSYS message (Sent via Port 25)"
.HTMLBody = strHTML
.Send
End With

' Clean up variables.
Set iMsg = Nothing
Set iConf = Nothing
Set Flds = Nothing

MsgBox "Mail Sent!"

 
Try using the default port which windows uses and see what happens, i.e. comment that line and let windows use the default port??
 
Nope doesn't work when i comment the Sendusing Line. An error message is given "The Sendusing configuration value is invalid"....

How could i be certain which port to use??? Where can i see which ports are used for what???..
Can this code be run on any client computer????
 
Mmm. Think I might be able to help although I am just learning this stuff myself. If my understanding is correct the settings you are using are not exactly right. The values that need to be set are SendUsing and SMTPServerPort. I'm not sure if SendUsingPort is valid. Anyway, I have successfully sent SMTP mail using the code below. Mail can be sent using the SMTP Virtual Server running under the local copy of IIS or using a network/remote service. The code below allows SMTP to be sent from an Access form using the Yahoo mail service. The sever and port values are provided by Yahoo:

Set oMail = CreateObject("CDO.Message")
Set oMailConfig = CreateObject("CDO.Configuration")

oMailConfig.Fields(" = 2

oMailConfig.Fields(" = "smtp.mail.yahoo.co.uk"
oMailConfig.Fields(" = 587
oMailConfig.Fields(" = 60

oMailConfig.Fields.Item(" = 1
oMailConfig.Fields(" = "accountname"
oMailConfig.Fields(" = "accountpassword"


oMailConfig.Fields.Update
oMail.configuration = oMailConfig

oMail.From = strSMTP_From
oMail.To = Trim(strTo)
oMail.CC = Trim(strCC)
oMail.BCC = Trim(strBCC)
oMail.Subject = strSubject
oMail.TextBody = strBody
If Nz(strAttachments) > "" Then
Do While InStr(1, strAttachments, ";") > 0
oMail.AddAttachment Trim((Left$(strAttachments, InStr(1, strAttachments, ";") - 1)))
strAttachments = Mid$(strAttachments, InStr(1, strAttachments, ";") + 1)
Loop
End If
oMail.Send
Set oMail = Nothing
Set oMailConfig = Nothing

The code below will send SMTP mail via the local Virtual SMTP Server running under IIS. This uses the default values for port and pickup directory. The port number is set in IIS, Default SMTP Virtual Server, Properties, Delivery, Outbound Connections.

Set oMail = CreateObject("CDO.Message")
Set oMailConfig = CreateObject("CDO.Configuration")
oMailConfig.Fields(" = 1
oMailConfig.Fields(" = "C:\Inetpub\Mailroot\Pickup"


oMailConfig.Fields(" = "localhost"
oMailConfig.Fields(" = 25
oMailConfig.Fields(" = 60

oMailConfig.Fields.Item(" = 0

oMailConfig.Fields.Update
oMail.configuration = oMailConfig

oMail.From = strSMTP_From
oMail.To = Trim(strTo)
oMail.CC = Trim(strCC)
oMail.BCC = Trim(strBCC)
oMail.Subject = strSubject
oMail.TextBody = strBody
If Nz(strAttachments) > "" Then
Do While InStr(1, strAttachments, ";") > 0
oMail.AddAttachment Trim((Left$(strAttachments, InStr(1, strAttachments, ";") - 1)))
strAttachments = Mid$(strAttachments, InStr(1, strAttachments, ";") + 1)
Loop
End If
oMail.Send
Set oMail = Nothing
Set oMailConfig = Nothing





Hanging on your every thread

Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top