CDO (do not receive email)
Hi guys,
I am looking to use CDO to send a message through my SMTP server. I get the messagebox saying the email has been sent but I never get the email. This is the code I am using:
VB Code:
Option Explicit
Const SMTP_SERVER As String = "mail.mydomain.com"
Const SMTP_PORT As Long = 25
Const MAIL_SUBJECT As String = "Message from Business Manager User."
Private objMessage As CDO.Message
Private Sub Form_Load()
ConfigureForm Me
End Sub
Private Sub cmdClose_Click()
If MsgBox("You are about to close this screen." & vbNewLine & _
"Are you sure you want to do that?", vbQuestion + vbYesNo, "Confirmation.") = vbYes Then
Unload Me
Else 'vbno
'do nothing
End If
End Sub
Private Sub cmdReset_Click()
If MsgBox("You are about to reset this screen." & vbNewLine & _
"Are you sure you want to do that?", vbQuestion + vbYesNo, "Confirmation.") = vbYes Then
txtEmailAddress.Text = vbNullString
txtMessage.Text = vbNullString
txtEmailAddress.SetFocus
Else 'vbNo
'do nothing
End If
End Sub
Private Sub cmdSend_Click()
On Error GoTo Err
Set objMessage = New CDO.Message
With objMessage
.Subject = MAIL_SUBJECT
.From = txtEmailAddress.Text
.To = MAIL_TO
.TextBody = txtMessage.Text
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = SMTP_SERVER
.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTP_PORT
.Configuration.Fields.Update
.Send
End With
Set objMessage = Nothing
If MsgBox("Your message to the authors was" & vbNewLine & _
"successfully sent.", vbInformation, "Email Message Sent.") = vbOK Then
Unload Me
End If
Exit Sub
Err:
If MsgBox("Your message to the authors could" & vbNewLine & _
"not be sent. Please try again later.", vbCritical, "Email Message Not Sent.") = vbOK Then
Unload Me
End If
End Sub
Re: CDO (do not receive email)
Everything works okay as far as the mail code ...
will need to check your SMTP server ...
I know you're changing the SMTP server and TO values right?
Also, what OS is this on?
Could be a CDO issue ... dont know ..
Re: CDO (do not receive email)
Quote:
Originally Posted by rory
Everything works okay as far as the mail code ...
will need to check your SMTP server ...
I know you're changing the SMTP server and TO values right?
Also, what OS is this on?
Could be a CDO issue ... dont know ..
yes, i put those in the to and smpt so that people dont try to login to my mail server. what about username/password for login... wouldnt i need that? if so, how would it be set? when it comes to the OS. i am on XP. i havent been able to get this CDO code to work even though it says the email has been sent. i might have to go and use MAPI instead.
Re: CDO (do not receive email)
also, just found out you can use the CDO constants ..
VB Code:
Set objMessage = New CDO.Message
With objMessage
.Subject = MAIL_SUBJECT
.From = MAIL_FROM
.To = MAIL_TO
.TextBody = MAIL_MESSAGE
.Configuration.Fields.Item(cdoSendUsingMethod) = 2
.Configuration.Fields.Item(cdoSMTPServer) = SMTP_SERVER
.Configuration.Fields.Item(cdoSMTPServerPort) = SMTP_PORT
.Configuration.Fields.Item(cdoSMTPAuthenticate) = 1
.Configuration.Fields.Item(cdoSendUserName) = "username"
.Configuration.Fields.Item(cdoSendPassword) = "password"
.Configuration.Fields.Update
.Send
End With
Set objMessage = Nothing
Re: CDO (do not receive email)
i have no idea. now i am getting a message failed message box when the username and the password are correct. i am going to give up with CDO. no point in wasting my time with this part of my app. It might be easier with MAPI.
Re: [RESOLVED] CDO (do not receive email)
Maybe a CDO issue ...
Can you send mail using that server and another program such as Outlook Express? I have an SMTP Server test program you can PM me for if you like .. ill put it on my site to download.
Rory
Re: [RESOLVED] CDO (do not receive email)
Quote:
Originally Posted by rory
Maybe a CDO issue ...
Can you send mail using that server and another program such as Outlook Express? I have an SMTP Server test program you can PM me for if you like .. ill put it on my site to download.
Rory
yes, i use outlook to connect to send email but i am required to authenticate using a username/password. i would have thought specifying this in CDO would have worked but have no clue. oh well.
Re: [RESOLVED] CDO (do not receive email)
Quote:
Originally Posted by BrailleSchool
yes, i use outlook to connect to send email but i am required to authenticate using a username/password. i would have thought specifying this in CDO would have worked but have no clue. oh well.
Download the SMTP Server Test program here (smtpTest_setup.zip) .. install and run .. enter all the info (user and pass also) and let me know if it sends mail .. this uses Winsock in VB .. i know this program works for auth as i used it in another program for a yahoo account in the US,
http://bahamassecurity.com/uploads/
I cant test Auth right now as my ISP blocks port 25 and doesnt require auth..
Re: CDO (do not receive email)
Quote:
Originally Posted by rory
Download the SMTP Server Test program here (smtpTest_setup.zip) .. install and run .. enter all the info (user and pass also) and let me know if it sends mail .. this uses Winsock in VB .. i know this program works for auth as i used it in another program for a yahoo account in the US,
http://bahamassecurity.com/uploads/
I cant test Auth right now as my ISP blocks port 25 and doesnt require auth..
ill try it and get back to you.
2 Attachment(s)
Re: [RESOLVED] CDO (do not receive email)
ok, i ran your app and the screen shots show what happens. seems like the hosting provider doesnt allow transport. ugh.
Re: [RESOLVED] CDO (do not receive email)
Strange .. you said it works in Outlook?
Is this a SMTP or HTTP server?
Re: [RESOLVED] CDO (do not receive email)
Quote:
Originally Posted by rory
Strange .. you said it works in Outlook?
Is this a SMTP or HTTP server?
SMTP/POP3 for email and i can use any kind of IMAP email client with no problem.
Re: CDO (do not receive email)
Can you telnet to the smtp server and port, then type HELP and see if it uses the AUTH command?
Do you require any other settings like SSL?
Re: CDO (do not receive email)
Quote:
Originally Posted by rory
Can you telnet to the smtp server and port, then type HELP and see if it uses the AUTH command?
i used hyperterminal and its not letting me do any commands, tried to use telnet in cpanel and its not doing squat right now
Quote:
Do you require any other settings like SSL?
no
Re: CDO (do not receive email)
telnet mail.domain.ext 25
wait for response ...
HELP
1 Attachment(s)
Re: CDO (do not receive email)
Quote:
Originally Posted by rory
telnet mail.domain.ext 25
wait for response ...
HELP
i did it from the command prompt instead and the capture shows what happened.
Re: CDO (do not receive email)
I dont have anyway too test auth right now ...but found this info ..
"This error occurs when authorisation is sent that isn't wanted/recognised by the receiving email server.
A solution to this problem is to leave out either the user name, password or both in the SMTP set-up "
Re: CDO (do not receive email)
Quote:
Originally Posted by rory
I dont have anyway too test auth right now ...but found this info ..
"This error occurs when authorisation is sent that isn't wanted/recognised by the receiving email server.
A solution to this problem is to leave out either the user name, password or both in the SMTP set-up "
you can only send and receive through the mail server when youre authenticated in outlook so it would have to apply in any other situation.
Re: CDO (do not receive email)
If i had access to a PC there with UltraVNC and the SMTP server i could figure it out for yah .. let me know .. ;)
Re: CDO (do not receive email)
Quote:
Originally Posted by rory
If i had access to a PC there with UltraVNC and the SMTP server i could figure it out for yah .. let me know .. ;)
i am not totally sure what you mean so can you elaborate for me?
Re: CDO (do not receive email)
Quote:
Originally Posted by BrailleSchool
i am not totally sure what you mean so can you elaborate for me?
was saying if i had access to a PC through UltraVNC then I could test the commands ... but if you want the source for the SMTP program PM me .. then you can play with the commands from your end..
Re: CDO (do not receive email)
Quote:
Originally Posted by rory
was saying if i had access to a PC through UltraVNC then I could test the commands ... but if you want the source for the SMTP program PM me .. then you can play with the commands from your end..
i can give you access if you like... how would this be done?