0
Answer

Network credentrials (SMTP) and button change code statement Q.

Oliwer Svensson

Oliwer Svensson

13y
8.4k
1
I'm kinda new into this C# SMTP mail coding, and have some few unawnsered questions..

The thing is that i have a code looking like this below, and my question is, can i change the "smtp.gmail.com" line to lets say "smtp.live.se" by type a code for a button click?

 SmtpClient Client = new SmtpClient("smtp.gmail.com", 25);
            Client.Credentials = new NetworkCredential("userName", "password");
            MailMessage msg = new MailMessage();
            msg.From = new MailAddress(textFrom.Text);
            msg.To.Add(new MailAddress(textTo.Text));
            msg.Subject = textSubject.Text;
            msg.Body = textBody.Text;

            Client.Port = 587;
            Client.EnableSsl = true;

And my second question is is there anyway you can type in your own credentials with a login form to a specificly smtp server depending on what button (question below) you have pressed?..

(Yes i know, i should read a lite bit more Head First books before asking too much..) But i would really appreciate if someone had any suggestions or ides.