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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CDO SendMail not working

Status
Not open for further replies.

jasonp45

Programmer
Aug 23, 2001
212
US
This code used to work fine; I suspect something's changed with my mailserver (which I don't have administrative access to):

Code:
   Public Sub SendMail()
    Dim oMessage 'as System.Web.Mail.SmtpMail
    Set oMessage = CreateObject("CDO.Message")
    With oMessage
    	.Configuration.Fields.Item ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusing")[/URL] = 2
    	.Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserverport")[/URL] = 25
    	.Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = MailServer
    	.Configuration.Fields.Update
    	.From = "me@mydomain.com"
    	.To = Recipient
    	.Subject = Subject
    	.HTMLBody = Body
      If Attachment <> "" Then .AddAttachment Attachment
    	.Send
    End With
    Set oMessage = Nothing  
  End Sub

It doesn't work anymore. I checked the address of my mailserver and it's correct.

I've tried playing around with the fields so I can directly authenticate using the username and password I have setup in my desktop mail client (Thunderbird), but it isn't working. I'm hoping I'm just leaving off a field or something?

Code:
  Public Sub SendMail()
    Dim oMessage 'as System.Web.Mail.SmtpMail
    Set oMessage = CreateObject("CDO.Message")
    With oMessage
    	.Configuration.Fields.Item ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")[/URL] = 1
    	.Configuration.Fields.Item ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/senduserName")[/URL] = "myusername"
    	.Configuration.Fields.Item ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendpassword")[/URL] = "xxxxxxxx"
     	.Configuration.Fields.Item ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/sendusingport")[/URL] = 2     
     	.Configuration.Fields.Item ("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/urlproxyserver")[/URL] = "server:80"
    	.Configuration.Fields.Item("[URL unfurl="true"]http://schemas.microsoft.com/cdo/configuration/smtpserver")[/URL] = MailServer
    	.Configuration.Fields.Update
    	.From = "me@mydomain.com"
    	.To = Recipient
    	.Subject = Subject
    	.HTMLBody = Body
      If Attachment <> "" Then .AddAttachment Attachment
    	.Send
    End With
    If err.Number <> 0 Then MsgBox err.Description
    Set oMessage = Nothing  
  End Sub

Thanks for any assistance.
 
Typing "o [mailserver's address] 25" returns a message stating 'SMTP service ready'.
 
do you actually get any errors?
I've only see it error out and no error and if this was the cause usually network issue.

[yinyang] Tranpkp [pc2]
 
Not sure if this will help but a while back I was having some issues using CDO and it was my virus software wreaking havoc.

thread222-1198241

Swi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top