예제 #1
0
파일: Mail.cs 프로젝트: avs009/gsf
 /// <summary>
 /// Sends a <see cref="Mail"/> message.
 /// </summary>
 /// <param name="from">The e-mail address of the <see cref="Mail"/> message sender.</param>
 /// <param name="toRecipients">A comma-separated or semicolon-seperated e-mail address list of the <see cref="Mail"/> message recipients.</param>
 /// <param name="ccRecipients">A comma-separated or semicolon-seperated e-mail address list of the <see cref="Mail"/> message carbon copy (CC) recipients.</param>
 /// <param name="bccRecipients">A comma-separated or semicolon-seperated e-mail address list of the <see cref="Mail"/> message blank carbon copy (BCC) recipients.</param>
 /// <param name="subject">The subject of the <see cref="Mail"/> message.</param>
 /// <param name="body">The body of the <see cref="Mail"/> message.</param>
 /// <param name="isBodyHtml">true if the <see cref="Mail"/> message body is to be formated as HTML; otherwise false.</param>
 /// <param name="attachments">A comma-separated or semicolon-seperated list of file names to be attached to the <see cref="Mail"/> message.</param>
 /// <param name="smtpServer">The name or IP address of the SMTP server to be used for sending the <see cref="Mail"/> message.</param>
 public static void Send(string from, string toRecipients, string ccRecipients, string bccRecipients, string subject, string body, bool isBodyHtml, string attachments, string smtpServer)
 {
     Mail email = new Mail(from, toRecipients, smtpServer);
     email.CcRecipients = ccRecipients;
     email.BccRecipients = bccRecipients;
     email.Subject = subject;
     email.Body = body;
     email.IsBodyHtml = isBodyHtml;
     email.Attachments = attachments;
     email.Send();
 }
예제 #2
0
        /// <summary>
        /// Sends an e-mail message containing the specified message.
        /// </summary>
        /// <param name="message">The message to be sent in the e-mail message.</param>
        public override void Write(string message)
        {
            StringBuilder messageBuilder = new StringBuilder();

            // Appends standard information to the bottom of the message.
            messageBuilder.Append(message);
            messageBuilder.AppendLine();
            messageBuilder.AppendLine();
            messageBuilder.Append("This trace message was sent from the machine ");
            messageBuilder.Append(Dns.GetHostName());
            messageBuilder.Append(" (");
            messageBuilder.Append(Dns.GetHostEntry(Dns.GetHostName()).AddressList[0].ToString());
            messageBuilder.Append(") at ");
            messageBuilder.Append(DateTime.Now);

            Mail mailMessage = new Mail(m_sender, m_recipient, m_smtpServer);
            mailMessage.Subject = "Trace message for " + AppDomain.CurrentDomain.FriendlyName;
            mailMessage.Body = messageBuilder.ToString();
            mailMessage.Send();
        }
예제 #3
0
파일: ErrorLogger.cs 프로젝트: avs009/gsf
 /// <summary>
 /// Logs encountered <see cref="Exception"/> to an e-mail message.
 /// </summary>
 /// <param name="exception"><see cref="Exception"/> that was encountered.</param>
 protected virtual void ExceptionToEmail(Exception exception)
 {
     // Log if enabled.
     if (m_logToEmail && !string.IsNullOrEmpty(m_contactEmail) && !m_suppressInteractiveLogging)
     {
         m_logToEmailOK = false;
         Mail email = new Mail(m_contactEmail, m_contactEmail);
         email.Subject = string.Format("Exception in {0} at {1}", ApplicationName, DateTime.Now.ToString());
         email.Body = GetExceptionInfo(exception);
         email.Attachments = GetScreenshotFileName();
         email.SmtpServer = m_smtpServer;
         email.Send();
         m_logToEmailOK = true;
     }
 }