Problems using CDO to send Email

D

Danny

Hi!

If you check Tools, References when you're in the code window, do you
actually have Microsoft CDO listed? Are you running Windows 2000?

Otherwise, I'm not dimming the configuration as a CDO.Configuration but as
an Object and then creating it later (so called late binding), and that works
_without_ having to set the References. This is a snippet from the code I'm
using (with various other parts gleaned from various suggestions that could
be helpful):

Public Sub SendMail(ByVal SendTo As String, ByVal Subject As String, ByVal
MessageText As String, Optional ByVal Attachment As String)
Dim Config As Object, Message As Object
Dim CDOSchema As String

CDOSchema = "http://schemas.microsoft.com/cdo/configuration/"
Set Message = CreateObject("CDO.Message")
Set Config = CreateObject("CDO.Configuration")
Config.Load -1
With Config.Fields
.Item(CDOSchema & "sendusing") = 2
.Item(CDOSchema & "smtpserver") = < your mail server name here >
'Only used if SMTP server requires Authentication
'.Item(strSch & "smtpauthenticate") = 1
'.Item(strSch & "sendusername") = "(e-mail address removed)"
'.Item(strSch & "sendpassword") = "APassword"
.Update
End With

With Message
Set .configuration = Config
.configuration.Load 1
.From = < sender alias, does not have to be a real mail address >
'.Sender = "(e-mail address removed)" 'Must be a real address I believe
.To = SendTo
.Subject = Subject
.TextBody = MessageText
'.HTMLBody = "Test <B>HTML</B> format!"
If Attachment <> "" Then .AddAttachment Attachment
.Send
End With
End Sub

I don't quite understand the Hotmail mention, if you want to send to a
Hotmail address you just mail it like above, stating your SMTP mail server,
which will then forward it to Hotmail.

Brgds

Danny
 
R

Rhonda

Thanks Danny.
I found the Reference for Microsoft CDO for NTS 1.2 Library listed, but
unchecked. That should make a big difference. Yes Win 2000 on my dev PC and
the PC my software will be used in.

I'd like to be able to send through Hotmail, using the Hotmail server as you
would in Outlook Express.
Thanks for the code I'll try it soon as I can.
 
R

Rhonda

Danny
I have it working!
Sometimes times I get a server error when I re-send to soon. Where can I
get ALL the properties, definitions, and syntax for CDO? Commands like:
..item(cdoURLProxyServer) = "server:80" , (cdoURLProxyBypass)="<local>",
etc.

As in your example, they are apparently not all necessary.
Thanks
 
D

Danny

Hi!

I'm glad it works. The detailed properties should be listed somewhere
through the MSN link I gave previously. Although there's so much there I've
actually never had the patience to go through it all.

I don't have problems with sending multiple emails rapidly in succession
(although I did actually have that originally when I was using SendObject pre
Outlook 2003). But I have CDO for Exchange 2000 instead of for NTS, so maybe
there is a difference. You can try to put in a short delay in the code before
sending the next mail.

Brgds

Danny
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Sending Access mail using smtp 1
email through CDO 1
cdo 0
Sending email from access using cdo. Help! 3
CDO-email 0
Error message sending Email via CDO 3
CDO Error Message 2
Error using CDO to send email 1

Top