mail





    public static void SendMail(string senderName, string subject, string iMessage)
    {
        // Exit Sub
        System.Net.Mail.SmtpClient xSMTP;
        System.Net.Mail.MailMessage xMessage;
        // Dim xAttachment As System.Net.Mail.Attachment
        SmtpClient mailclient = new SmtpClient("192.16.11.19");
        // String.IsNullOrEmpty(GetColValue(MSG_DEF_S2_0019.BoatID))
        try {
            xSMTP = new System.Net.Mail.SmtpClient();
            xSMTP.Host = "192.16.11.19";
            xSMTP.Port = 25;
            xMessage = new System.Net.Mail.MailMessage();
            xMessage.From = new System.Net.Mail.MailAddress("xhtsai@molicel.com", senderName);


            xMessage.To.Add(new System.Net.Mail.MailAddress("xhtsai@molicel.com", "Tsai"));
            xMessage.IsBodyHtml = true;
            xMessage.BodyEncoding = System.Text.Encoding.UTF8;
            xMessage.Subject = ("[A] " + subject.Replace("\r\n", " : "));
            xMessage.Priority = MailPriority.High;
            // <div style="font-size: 10pt; color: gray; font-family: Arial; text-decoration: underline">TTTTTAAA</div>
            string frontbody = "<div style=\'font-size: 10pt; color: gray; font-family: Arial\'>";
            string backbody = "</div>";
            xMessage.Body = "<b>CIM PC Report (ClientAP Version), 請參考!!</b><p><p><p><p>";
            xMessage.Body += "<b>本信件由  CIM PC 自動發出, 針對 alarm report, 請檢查</b>";



            xMessage.Body = (xMessage.Body + ("<p><p> 說明: " + iMessage));
            xMessage.Body += "<p><p><p><p><p><p><p><p><p><p><p><p><p>";
            xMessage.Body = (xMessage.Body + ("<p>"
                        + (frontbody + (" -- CIM PC 有任何問題請來電或來信 -- " + backbody))));
            // xAttachment = New System.Net.Mail.Attachment(FileName)
            // xMessage.Attachments.Add(xAttachment)
            xSMTP.Send(xMessage);
            // xAttachment.Dispose() : xAttachment = Nothing
            xMessage.Dispose();
            xMessage = null;
            xSMTP = null;
        }
        catch (System.Net.Mail.SmtpException ex) {
           // Log2DBAlarm(("SendMail 1: " + ex.Message));
        }
        catch (Exception ex) {
           // Log2DBAlarm(("SendMail 2: " + ex.Message));
        }
     
    }


留言

熱門文章