how to connect MailKit or SMTPClient to zenno C#

Besedi

Client
Регистрация
04.03.2019
Сообщения
234
Благодарностей
41
Баллы
28

absolutely newbie with c#, how can I use default SMTPclient?
I tried smt like that:

string server= "smtp.aol.com";
int port = 465;
public static void CreateTestMessage1(string server, int port)
{
string to = "[email protected]";
string from = "[email protected]";
string subject = "Using the new SMTP client.";
string body = @"Using this new feature, you can send an email message from an application very easily.";
MailMessage message = new MailMessage(from, to, subject, body);
SmtpClient client = new SmtpClient(server, port);
// Credentials are necessary if the server requires the client
// to authenticate before it will send email on the client's behalf.
client.Credentials = CredentialCache.DefaultNetworkCredentials;
client.Send(message);

}
But can't understand how I use my credential, what's var I need to use?
And I recieve a error about first line...:bh:
"
Compiling code Error in action "CS1513" "expected }". [Line: 1; Column: 16]" "
 

Besedi

Client
Регистрация
04.03.2019
Сообщения
234
Благодарностей
41
Баллы
28
any one suggestions?
 

VladZen

Administrator
Команда форума
Регистрация
05.11.2014
Сообщения
22 453
Благодарностей
5 913
Баллы
113
If you are newbie in C#, why would not you use built-in Send emals functionality?
 

Besedi

Client
Регистрация
04.03.2019
Сообщения
234
Благодарностей
41
Баллы
28
If you are newbie in C#, why would not you use built-in Send emals functionality?
It's not work properly. I already tried, as well as buy socks with open 465 ports to test but it's also unfortunely unseccessfully. I can connect smtp account to thunderbird and send some messages from there, but when I connect email (in zenno 7.7) it's messaged me that "all right" but error when I trying to send any email.
Error: The SMTP server has unexpectedly disconnected.
 

myndeswx

Client
Регистрация
15.05.2017
Сообщения
436
Благодарностей
104
Баллы
43
I would highly suggest you to use the API instead, much easier, pretty much every mailing service I have used has a simple API.
 

Кто просматривает тему: (Всего: 1, Пользователи: 0, Гости: 1)