Console App, Using TextBoxField to Send Email.

red

Member
Joined
Oct 16, 2013
Messages
15
Programming Experience
1-3
Ok good evening

here is what i am trying to acomplish, i have a console application now i addeda windows reference to it and it has this 'using System.Windows.Forms;' now i want to do something again like add a TextBox or RichText to the app so i can output messages like this to send email

C#:
            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage(); //create the message
            msg.To.Add("username@gmail.com)           
        msg.From = new MailAddress("username@gmail.com", "username", System.Text.Encoding.UTF8);
            msg.Subject = "TestMail";
            msg.SubjectEncoding = System.Text.Encoding.UTF8;
            msg.Body = "ciao ale"; // Here it should use the Rich TextBox or TextField.
            msg.BodyEncoding = System.Text.Encoding.UTF8;
            msg.IsBodyHtml = false;
            msg.Priority = MailPriority.High;
            SmtpClient client = new SmtpClient(); //Network Credentials for Gmail
            client.Credentials = new System.Net.NetworkCredential("username@gmail.comassword");
            client.Port = 587;
            client.Host = "smtp.gmail.com";
            client.EnableSsl = true;
            Attachment data = new Attachment(Program.path);
            msg.Attachments.Add(data);
        msg.Send();

I am Lost about this. How do i go about it..
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,273
Location
Sydney, Australia
Programming Experience
10+
That doesn't really make sense. The point of a Console app is that it doesn't have a GUI and you interact with it via the console. If you want to use Windows Forms controls then create a Windows Forms app, plain and simple.
 
Top Bottom