Problem with CDONTS email
Hi Guru, I am trying to send email using CDONTS but the email is not sent and a message "Email is sent" is shown. Please, inform me what's wrong with the code below, thank's for your help;
Sub SendEmail(ByVal From As String, ByVal sendto As String, ByVal subject As String, _
ByVal EmailText As String, Optional ByVal Attachment As String)
Dim rseomail As CDONTS.NewMail
On Error GoTo NextTry
Set rseomail = CreateObject("CDONTS.NewMail")
rseomail.From = From ' "[email protected]"
rseomail.To = sendto ' "[email protected]"
rseomail.subject = subject ' "Re: Email testing"
rseomail.Body = EmailText ' "This is to test email CDONTS"
rseomail.attachfile (Attachment) ' "c:a.txt"
rseomail.Importance = 0
rseomail.Send
MsgBox "Email is sent."
Exit Sub
NextTry:
Call SendEmailOutlook(sendto, subject, EmailText, Attachment)
End Sub
Re: Problem with CDONTS email
Quote:
Originally Posted by gracesup
Hi Guru, I am trying to send email using CDONTS but the email is not sent and a message "Email is sent" is shown. Please, inform me what's wrong with the code below, thank's for your help;
Sub SendEmail(ByVal From As String, ByVal sendto As String, ByVal subject As String, _
ByVal EmailText As String, Optional ByVal Attachment As String)
Dim rseomail As CDONTS.NewMail
On Error GoTo NextTry
Set rseomail = CreateObject("CDONTS.NewMail")
rseomail.From = From ' "
[email protected]"
rseomail.To = sendto ' "
[email protected]"
rseomail.subject = subject ' "Re: Email testing"
rseomail.Body = EmailText ' "This is to test email CDONTS"
rseomail.attachfile (Attachment) ' "c:a.txt"
rseomail.Importance = 0
rseomail.Send
MsgBox "Email is sent."
Exit Sub
NextTry:
Call SendEmailOutlook(sendto, subject, EmailText, Attachment)
End Sub
hi,
in attachfile you have missed the slash "\"
and you are not closing the cdonts object.
thanks
Re: Problem with CDONTS email
CDONTS line length is limited to 74 characters, if you are trying to send more than this, then it might create a problem.
regards
Re: Problem with CDONTS email
Hi, thank's for trying but it still does not work after I add "\" , close the cdonts object, and the text is less than 74 char.
Re: Problem with CDONTS email
Quote:
Originally Posted by gracesup
Hi, thank's for trying but it still does not work after I add "\" , close the cdonts object, and the text is less than 74 char.
I think the main problem is with your SMTP service configuration,config the SMTP properly delivering email.
You can check the mailroot for outgoing mails.If the mails are there just config SMTP properly.
Rudraksh
Re: Problem with CDONTS email
Hi Rudraksh, I think you are right, I checked the mailroot and the outgoing mails are there. I config the SMTP for a single computer with IP 127.0.0.1 but it still doesn't work. Could it be my ISP that prevents emailing from vb or I didn't config correctly? Thank's for your info.