Гость
Целевая тема:
Создать новую тему:
Автор:
Форумы / WCF, Web Services, Remoting [игнор отключен] [закрыт для гостей] / smtp Web Service / 2 сообщений из 2, страница 1 из 1
24.08.2009, 12:50
    #36159605
prBoris
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
smtp Web Service
Есть сервис

Интерфейс
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
[ServiceContract]
    public interface IServiceSendSMTP
    {

        [OperationContract]
        string GetData(int value);

        [OperationContract]
        CompositeType GetDataUsingDataContract(CompositeType composite);

        // TODO: Add your service operations here
        [OperationContract]
        bool SendMail(string Mail, string Subject, string Body);
    }


    // Use a data contract as illustrated in the sample below to add composite types to service operations.
    [DataContract]
    public class CompositeType
    {
        bool boolValue = true;
        string stringValue = "Hello ";

        [DataMember]
        public bool BoolValue
        {
            get { return boolValue; }
            set { boolValue = value; }
        }

        [DataMember]
        public string StringValue
        {
            get { return stringValue; }
            set { stringValue = value; }
        }
    }
Сервис
Код: plaintext
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
public class ServiceSendSMTP : IServiceSendSMTP
    {
        public string GetData(int value)
        {
            return string.Format("You entered: {0}", value);
        }
        
        public CompositeType GetDataUsingDataContract(CompositeType composite)
        {
            if (composite.BoolValue)
            {
                composite.StringValue += "Suffix";
            }
            return composite;
        }

        #region IService1 Members


        public bool SendMail(string Mail, string Subject, string Body)
        {
            SmtpClient Smtp = new SmtpClient("smtp.mail.ru",25);
            System.Net.NetworkCredential SmtpUser = new System.Net.NetworkCredential("cam","****");
            Smtp.Credentials = SmtpUser;
            Smtp.UseDefaultCredentials = false;
            MailMessage message = new MailMessage("ca@mail.ru", Mail, Subject, Body);
            Smtp.Send(message);
            return true;
        }

Запускается нормально но при добавление в приложение выдает ошибку
Код: plaintext
1.
2.
3.
            ServiceReferenceMail.ServiceSendSMTPClient send = new smtp.ServiceReferenceMail.ServiceSendSMTPClient();
            bool sends = send.SendMail("boris@gmail.com", "test", "tesssrt");
            MessageBox.Show(sends.ToString());
...
Рейтинг: 0 / 0
24.08.2009, 13:05
    #36159630
prBoris
Участник
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
smtp Web Service
вопрос закрыт!!!
...
Рейтинг: 0 / 0
Форумы / WCF, Web Services, Remoting [игнор отключен] [закрыт для гостей] / smtp Web Service / 2 сообщений из 2, страница 1 из 1
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]