Click here to Skip to main content
15,887,135 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All, I am trying to send an email from my app. Here is some of my code:
VB
dynamic mail = null;
                    //--------Send Message-----------------------
                 
                //    mail = Interaction.CreateObject("CDO.Message");
                    mail = Server.CreateObject("CDO.Message");
                    mail.Subject = "Password set to expire";
                    mail.From = "fromAddress";
                
                  //  mail.To = Session("uemail");
              //      mail.To = HttpContext.Current.Session["uemail"];
                    mail.To = "toAddress";
               //     mail.TextBody = mtext;
                    mail.TextBody = "Hello World";
                    mail.Send();
                    mail = null;


This was in VB and I converted it online. Intellisense does not recognize the word "Interaction". I tried Server and Intellisense gave me some options. When I get to mail.Send(); I am getting error "The SendUsing configuration value is invalid." Any suggestions or ideas would be greatly appreciated. I do not have much experience with C#. I am trying to test by hardcoding the to and from addresses.

Thank-you,

D-Bar
Posted
Updated 5-Nov-12 9:00am
v2

 
Share this answer
 
Hi
I am sending an email using gmailaccount here.

C#
using System.Net.Mail;

 private void button1_Click(object sender, RoutedEventArgs e)
        {
 string footer = "If you have any questions about appointment";
            string subject = "Appointment Canceled";
            string body = "Hi" + " " + "sent from google" + "\n\n" + footer;

            MailMessage message = new MailMessage();

            message.From = new MailAddress("Ngqandu.Anele@gmail.com");
            message.To.Add(new MailAddress("Anele.Ngqandu@live.nmmu.ac.za"));
            message.Subject = subject;
            message.Body = body;

            SmtpClient client = new SmtpClient();
            client.Credentials = new System.Net.NetworkCredential("Ngqandu.Anele@gmail.com", "myGMAILpassword");

            client.Port = 587;
            client.Host = "smtp.gmail.com";
            client.EnableSsl = true;
            try
            {
                client.Send(message);
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }




vote if it helps...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900