Example #1
0
    public void sendMail(List <string> l)
    {
        for (int i = 0; i < l.Count; i++)
        {
            try
            {
                MailMessage mail       = new MailMessage();
                SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");
                mail.Body = "hello " + l[i].ToString() + " " + l[i + 1].ToString();
                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add(l[i + 2].ToString());
                mail.Subject = "Test Mail";
                mail.Body   += "\n";

                string[] ss = l[i + 3].ToString().Split(';');
                for (int j = 0; j < ss.Count(); j++)
                {
                    ServiceReference1.StockQuoteSoapClient client3 = new ServiceReference1.StockQuoteSoapClient();
                    string st  = client3.GetQuote(ss[j].ToString());
                    string str =
                        @"<?xml version=""1.0""?>" + "<root>" + st + "</root>";
                    XDocument doc = XDocument.Parse(str);
                    string    sym = doc.Root.Element("StockQuotes").Element("Stock").Element("Symbol").Value;
                    mail.Body += "Symbol=" + sym + "\n";
                    String last = doc.Root.Element("StockQuotes").Element("Stock").Element("Last").Value;
                    mail.Body += "Last=" + last + "\n";
                    String d = doc.Root.Element("StockQuotes").Element("Stock").Element("Date").Value;
                    mail.Body += "Date=" + d + "\n";
                    String t = doc.Root.Element("StockQuotes").Element("Stock").Element("Time").Value;
                    mail.Body += "Time=" + t + "\n";
                    String c = doc.Root.Element("StockQuotes").Element("Stock").Element("Change").Value;
                    mail.Body += "Change=" + c + "\n";
                    String o = doc.Root.Element("StockQuotes").Element("Stock").Element("Open").Value;
                    mail.Body += "Open=" + o + "\n";
                    String h = doc.Root.Element("StockQuotes").Element("Stock").Element("High").Value;
                    mail.Body += "High=" + h + "\n";
                    String lw = doc.Root.Element("StockQuotes").Element("Stock").Element("Low").Value;
                    mail.Body += "Low=" + lw + "\n";
                    String vol = doc.Root.Element("StockQuotes").Element("Stock").Element("Volume").Value;
                    mail.Body += "Volume=" + vol + "\n";
                    String MktCap = doc.Root.Element("StockQuotes").Element("Stock").Element("MktCap").Value;
                    mail.Body += "MktCAp=" + MktCap + "\n";
                    String prev = doc.Root.Element("StockQuotes").Element("Stock").Element("PreviousClose").Value;
                    mail.Body += "Previous Close=" + prev + "\n";
                    String pc = doc.Root.Element("StockQuotes").Element("Stock").Element("PercentageChange").Value;
                    mail.Body += "Percentage Change=" + pc + "\n";
                    String an = doc.Root.Element("StockQuotes").Element("Stock").Element("AnnRange").Value;
                    mail.Body += "Annual Range=" + an + "\n";
                    String earns = doc.Root.Element("StockQuotes").Element("Stock").Element("Earns").Value;
                    mail.Body += "Earns=" + earns + "\n";
                }
                SmtpServer.Port        = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("testxyz477", "Kishan123");
                SmtpServer.EnableSsl   = true;

                SmtpServer.Send(mail);
                i = i + 3;
            }
            catch (Exception ex)
            {
            }
        }
    }
Example #2
0
    public void sendMail(List<string> l)
    {
        for (int i = 0; i < l.Count; i++)

            try
            {
                MailMessage mail = new MailMessage();
                SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
                mail.Body = "hello " + l[i].ToString() + " " + l[i + 1].ToString();
                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add(l[i + 2].ToString());
                mail.Subject = "Test Mail";
                mail.Body += "\n";

                string[] ss = l[i + 3].ToString().Split(';');
                for (int j = 0; j < ss.Count(); j++)
                {
                    ServiceReference1.StockQuoteSoapClient client3 = new ServiceReference1.StockQuoteSoapClient();
                    string st = client3.GetQuote(ss[j].ToString());
                    string str =
        @"<?xml version=""1.0""?>" + "<root>" + st + "</root>";
                    XDocument doc = XDocument.Parse(str);
                    string sym = doc.Root.Element("StockQuotes").Element("Stock").Element("Symbol").Value;
                    mail.Body += "Symbol=" + sym + "\n";
                    String last = doc.Root.Element("StockQuotes").Element("Stock").Element("Last").Value;
                    mail.Body += "Last=" + last + "\n";
                    String d = doc.Root.Element("StockQuotes").Element("Stock").Element("Date").Value;
                    mail.Body += "Date=" + d + "\n";
                    String t = doc.Root.Element("StockQuotes").Element("Stock").Element("Time").Value;
                    mail.Body += "Time=" + t + "\n";
                    String c = doc.Root.Element("StockQuotes").Element("Stock").Element("Change").Value;
                    mail.Body += "Change=" + c + "\n";
                    String o = doc.Root.Element("StockQuotes").Element("Stock").Element("Open").Value;
                    mail.Body += "Open=" + o + "\n";
                    String h = doc.Root.Element("StockQuotes").Element("Stock").Element("High").Value;
                    mail.Body += "High=" + h + "\n";
                    String lw = doc.Root.Element("StockQuotes").Element("Stock").Element("Low").Value;
                    mail.Body += "Low=" + lw + "\n";
                    String vol = doc.Root.Element("StockQuotes").Element("Stock").Element("Volume").Value;
                    mail.Body += "Volume=" + vol + "\n";
                    String MktCap = doc.Root.Element("StockQuotes").Element("Stock").Element("MktCap").Value;
                    mail.Body += "MktCAp=" + MktCap + "\n";
                    String prev = doc.Root.Element("StockQuotes").Element("Stock").Element("PreviousClose").Value;
                    mail.Body += "Previous Close=" + prev + "\n";
                    String pc = doc.Root.Element("StockQuotes").Element("Stock").Element("PercentageChange").Value;
                    mail.Body += "Percentage Change=" + pc + "\n";
                    String an = doc.Root.Element("StockQuotes").Element("Stock").Element("AnnRange").Value;
                    mail.Body += "Annual Range=" + an + "\n";
                    String earns = doc.Root.Element("StockQuotes").Element("Stock").Element("Earns").Value;
                    mail.Body += "Earns=" + earns + "\n";
                }
                SmtpServer.Port = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("testxyz477", "Kishan123");
                SmtpServer.EnableSsl = true;

                SmtpServer.Send(mail);
                i = i + 3;
            }
            catch (Exception ex)
            {

            }
    }