Question Locked

Setting up CDO to work through SmarterMail

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I want to send CDO email through the SmarterMail installed on my Windows 2003 server. I have Outlook Express set up on the server and am able to send through the SmarterMail set up using the following settings:

Incoming mail server: 127.0.0.1
Outgoing mail server: 127.0.0.1
Account name: domain@domain.com (using the email address already set up on SmarterMail with one of my domains)
Password: xxxx

However, when I try to use these settings in my Functions file that specifies the mail server, it just ignores them and continues to send email through the IIS server. All the coding is ASP.

I'm sure it is still sending through the IIS server since the IP used is the one you see when you send email through the IIS server and also email didn't work when I stopped the IIS SMTP Service temporarily, but Smartermail was still operating.

Any suggestions?

Thanks in Advance,
Bill

6 replies

by scott_heath

There can be only on service on an IP listing on a specific port. So I'm not sure how this can be happening if both are set to use port 25. FYI - Sending email and receiving are to different things. When you log into a POP server it is normally logging into port 110. Since the IIS SMTP service is running on port 25, this works. Put SmarterMail's smtp service on another port. Or bind it to another IP.

Regards,
Scott

http://scottisageek.spaces.live.com

by office

Hi Scott,

Thanks for your reply. SmarterMail is already set to use port 587 and is working fine. I can send email through SmarterMail using Outlook express with the settings mentioned in my first posting. SmarterMail is also set to use the second IP address and that works fine, both with SmarterMail's webmail system and with Outlook Express. The problem is with CDO email I am trying to send through SmarterMail. I want that email to use SmarterMail and the second IP rather than IIS SMTP and the first IP. Incoming email is not an issue since I don't use the server for incoming email.

Bill

by scott_heath

And you have specified port 587 in your function? Can I see your code?

by office

Hi Scott,

Sure - here it is. I have tried enclosing the port number (587) in double quotes and without quotes. It doesn't make any difference. I think it still goes out through Port 25 and IIS SMTP regardless of what I put there.

Public Function SendEmailMessageWithAttachment(strFromAddress, strToAddress, strSubject, strHTMLBody, strAttachmentPath)

Const cdoSendUsingPort = 2

Set objMail= Server.CreateObject("CDO.Message")

'Const cdoIIS = 1

With objMail
'.Configuration.Load cdoIIS
.From = strFromAddress
.To = strToAddress
.Subject = strSubject
.HTMLBody = strHTMLBody

If strAttachmentPath<>"" Then .AddAttachment strAttachmentPath

'.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
'.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "10.10.236.90"

'To configue using the same external mail server as JobsNetwork, use these settings instead.
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "http://127.0.0.1"
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = "587"
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = "1"
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "domain@domain.com"
.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxxxxxxxx"

.Configuration.Fields.Update

.Send
End With

Set objMail = Nothing

If Err.number=0 Then
SendEmailMessageWithAttachment=True
Else
SendEmailMessageWithAttachment=False
End If

End Function

by scott_heath

You have to create an instance of the CDO.Configuration object and then assign that object to you mail object. Below is an block from some code I wrote to send automated emails:

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

' ** Set mail server values
iConf.Load -1
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "10.0.0.1" '<-- This is the IP of your SMTP server!
.Update
End With

' ** Add attachments
If oFSO.FileExists("c:\path\filename.txt") Then
iMsg.AddAttachment "c:\path\filename.txt"
Else
MsgBody = MsgBody & vbCrLf & "File to attach was missing."
End IF

' ** Set message properites
With iMsg
Set .Configuration = iConf
.To = MsgRecipients
.CC = ""
.BCC = ""
.From = MsgFrom
.Subject = MsgSubject
.TextBody = MsgBody
End With

' **Send Message!
err.clear
iMsg.Send
If err.Number = 0 Then
LogFile.Writeline Now & " - Action: " & Action & " - Mail sent successfully"
Else
LogFile.Writeline Now & " - " & err.Description
End IF

Check out the script on my Skydrive. You can get to it from my blog.

Regards,
Scott

http://scottisageek.spaces.live.com

This discussion is closed to new replies.