2012/8/5

FTP檔案存取及email通知

http://pastie.org/4392989

email function:
private static void emailfunction(int intinsert)
        {
            MailMessage emailsend = new MailMessage();           
            SmtpClient smtpClient = new SmtpClient();
            string ipono = "PO";
            if (intinsert > 1)
            {
                ipono = "POs";
            }
            //email
            try
            {
                MailAddress fromAddress = new MailAddress("email address");
                emailsend.From = fromAddress;
                emailsend.To.Add("email address");
                //emailsend.To.Add("email address");
                //emailsend.To.Add("email address");
                emailsend.Subject = "[VIP_PO_AutoGet]";
                emailsend.IsBodyHtml = true;
                if (intinsert == 0)
                {
                    emailsend.Body = "Can't find the file on the FTP serve.
Please do not reply this message and check it on the FTP server! Thanks!";
                }
                else
                {
                    emailsend.Body = "VIP_PO_AutoGet Daily Schedule Program had inserted [" + intinsert + "] new " + ipono + " successfully in the DataBase.
Please do not reply this message and check it in the database! Thanks!";
                }               
                smtpClient.Host = "172.16.10.46";
                smtpClient.Port = 25;
                smtpClient.Send(emailsend);
            }
            catch (Exception e)
            {
                LogInfo(e.Message.ToString() + DateTime.Now.ToString("yyyyMMdd"));
            }
        }

沒有留言:

張貼留言