コード例 #1
0
        private List <MailMessage> CreateMessage()
        {
            MyProxy proxy;

            proxy = new MyProxy();
            //Console.WriteLine("Client is running at " + DateTime.Now.ToString());

            try
            {
                var result1            = proxy.GetBirthdays();
                List <MailMessage> msg = new List <MailMessage>();
                foreach (Employee emp in result1)
                {
                    MailDefinition md = new MailDefinition();
                    md.From       = "*****@*****.**";
                    md.IsBodyHtml = true;
                    md.Subject    = "Happy Birthday!";

                    ListDictionary replacements = new ListDictionary();
                    replacements.Add("{FirstName}", emp.Name);
                    replacements.Add("{LastName}", emp.Lastname);

                    string body = "Happy BirthDay  " + emp.Name + " " + emp.Lastname;

                    msg.Add(md.CreateMailMessage("*****@*****.**", replacements, body, new System.Web.UI.Control()));

                    //return msg;
                }


                return(msg);
            }

            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                proxy.Close();
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: amitchourasiya/birthday
        static void Main(string[] args)
        {
            MyProxy proxy;

            proxy = new MyProxy();

            var checkServiceLink = proxy.CheckConnection();

            if (checkServiceLink == "Service is Up")
            {
                Console.WriteLine("Client is running at " + DateTime.Now.ToString());

                try
                {
                    var result = proxy.GetBirthdays();

                    foreach (Employee record in result)
                    {
                        Console.WriteLine("Happy Birthday {0}\t{1}", record.Name, record.Lastname);
                    }
                    Console.ReadLine();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message.ToString());
                }
                finally
                {
                    proxy.Close();
                }
            }
            else
            {
                Console.WriteLine("Services are Temporarily Unavailable, Please start ServiceHost and try again");
                Console.ReadLine();
            }
        }