Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Распределённые приложения и сеть > не могу отправить email с System.Web.Mail.SmtpMail


Автор: jxr 15.9.2005, 21:32
Вот симпл отправител СМТП протоколом !
Исключение :
Could not access 'CDO.Message' object.

Код

using System;
using System.Net;
using System.Web.Mail;
class MailTest
{
    public static void Main()
    {
        string from ="чччч@nm.ru";
        string to = "чччч[email protected]";
        string subject = "This is a test mail message from JxR!";
        string body = "Hi Katie, I hope things are going well today."+" Lion 3-0 Real Madrid";
        SmtpMail.SmtpServer = "smtp.newmail.ru";
        //try
        try{
        SmtpMail.Send(from, to, subject, body);
        Console.Write("Message has sent !");}
        //if error
        catch(Exception e){
        Console.Write(e.Message);}
        
        Console.ReadLine();
    }
}



Что здесь не так ?
Спосибо !
Добавлено @ 21:36
Email address is not true in this code ! Universal
[email protected]
[email protected]
smtp server: smtp.newmail.ru

Автор: arilou 16.9.2005, 10:38
1) Приведите пожалуйста полный текст exception'а
2) Посмотрите на http://www.systemwebmail.com, большая часть проблем там описана.

Автор: jxr 18.9.2005, 02:32
Код

using System;
using System.Net;
using System.Web.Mail;
class MailTest
{
    public static void Main()
    {
        MailMessage mail = new MailMessage();
        mail.From="[email protected]";
        mail.To="[email protected]";
        mail.Subject="This is a test mail message from JxR!";
        mail.Body="Hi Katie, I hope things are going well ";
        SmtpMail.SmtpServer = "smtp.newmail.ru";
        //try
        try{
        SmtpMail.Send(mail);
        Console.Write("Message has sent !");}
        //if error
        catch(Exception e){
        Console.Write(e.Message);}
        
        Console.ReadLine();
    }
}


И так можна !

Я http://www.systemwebmail.com сайт но не мог понять что же такое
'CDO.Message' и вообше что сним сделать ?
Помогите !

Автор: jxr 18.9.2005, 04:06
Может так !
[email protected]
[email protected]

Значить так user_a отправляеть письмо user_b. В таком случае в программе SmtpMail.SmtpServer должен быт у SmtpServer user_b. ДА !
или SmtpServer user_a ???

Автор: mr.DUDA 18.9.2005, 21:45
Вот код, чтобы посмотреть подробное сообщение от сервера:
Код

        catch(Exception e)
        {
            Console.Write(e.InnerException.InnerException.Message);
        }

к примеру, у меня было: "Сервер отклонил адрес отправителя. Отклик сервера: 575 [email protected] sender requires authentication".

Проблема решается выставлением SMTP-аутентификации.

P.S.
CDO (Collaboration Data Objects) - это средства для отправки email-сообщений.

P.S. (2)
аутентификацию и адрес SMTP-сервера нужно выставлять для аккаунта, отправляющего почту. Каким образом это делается - надо поискать по форуму, недавно была похожая тема, с советом как добавлять данные для SMTP-аутентификации.

Автор: jxr 18.9.2005, 23:06
Код

The following exception occurred: System.Web.HttpException: Could not access 'CDO.Message' object. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Runtime.InteropServices.COMException (0x8004020F): The server rejected one or more recipient addresses. The server response was: 553 sorry authorization failed or you have have reached maximum messages in a hour. (#5.7.1)

   --- End of inner exception stack trace ---
   at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
   at System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters)
   at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
   --- End of inner exception stack trace ---
   at System.Web.Mail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
   at System.Web.Mail.CdoSysHelper.Send(MailMessage message)
   at System.Web.Mail.SmtpMail.Send(MailMessage message)
   at MailTest.Main()
The following InnerException reported: System.Runtime.InteropServices.COMException (0x8004020F): The server rejected one or more recipient addresses. The server response was: 553 sorry authorization failed or you have have reached maximum messages in a hour. (#5.7.1)


Вот Exception's !

e.InnerException.InnerException.ToString()
e.ToString()

Автор: mr.DUDA 19.9.2005, 09:33
В чём проблема ? Прочитать еррор на английском ?

Цитата(jxr @ 18.9.2005, 23:06)
The server rejected one or more recipient addresses. The server response was: 553 sorry authorization failed or you have have reached maximum messages in a hour. (#5.7.1)


Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)