Esempio n. 1
0
 public static void SendSuggestion(string Sender, RecipientEmails RecipientList, string Subject, string BodyText)
 {
     SendNotification(Sender, RecipientList, "G.C.P Suggestion: " + Subject, BodyText, MailPriority.High);
 }
Esempio n. 2
0
        public static IAsyncResult SendNotificationAsync(string Sender, RecipientEmails RecipientList, string Subject, string BodyText, MailPriority Priority)
        {
            try
            {

                //(1) Create the MailMessage instance
                using (MailMessage mm = new MailMessage(Sender, RecipientList.To))
                {
                    string strBody = "<div style=\'color:#4B6C8B; font-size:1.0em; font-family:Century Gothic,Verdana,Arial,Helvetica,sans-serif;\'>";
                    strBody += BodyText + " </div>";

                    //(2) Assign the MailMessage's properties
                    mm.Subject = Subject;
                    mm.Body = strBody;
                    mm.IsBodyHtml = true;
                    mm.Priority = Priority;
                    if (RecipientList.Cc != Constants.vbNullString)
                    {
                        mm.CC.Add(RecipientList.Cc);
                    }
                    if (RecipientList.Bcc != Constants.vbNullString)
                    {
                        mm.Bcc.Add(RecipientList.Bcc);
                    }

                    //(3) Create the SmtpClient object
                    SmtpClient smtp = new SmtpClient();

                    try
                    {
            RetrySend:
                        string userState = "NotificationSent";
                        smtp.SendAsync(mm, userState);
                    }
                    catch (SmtpFailedRecipientException ex)
                    {
                        switch (ex.StatusCode)
                        {
                            case SmtpStatusCode.MailboxBusy:
                            case SmtpStatusCode.TransactionFailed:
                                goto RetrySend;
                            default:
                                break;
                        }
                    }
                    catch (SmtpException ex)
                    {
                        switch (ex.StatusCode)
                        {
                            case SmtpStatusCode.MailboxBusy:
                            case SmtpStatusCode.TransactionFailed:
                                goto RetrySend;
                            default:
                                break;
                        }
                    }
                    catch (System.Exception)
                    {
                    }
                }

            }
            catch (System.Exception)
            {
            }

            return new MailNotificationResult();
        }
Esempio n. 3
0
 public static void SendComplaint(string Sender, RecipientEmails RecipientList, string Subject, string BodyText)
 {
     SendNotification(Sender, RecipientList, "Complaint: " + Subject, BodyText, MailPriority.High);
 }
Esempio n. 4
0
 public static void SendNotification(string Sender, RecipientEmails RecipientList, string Subject, string BodyText, MailPriority Priority)
 {
     SendNotification(Sender, RecipientList, Subject, BodyText, MailPriority.Normal, null);
 }
Esempio n. 5
0
        public static void SendNotification(string Sender, RecipientEmails RecipientList, string Subject, string BodyText, MailPriority Priority, List<Attachment> Attachments)
        {
            try
            {

                //(1) Create the MailMessage instance
                using (MailMessage mm = new MailMessage(Sender, RecipientList.To))
                {
                    string strBody = "<div style=\'color:#4B6C8B; font-size:1.0em; font-family:Century Gothic,Verdana,Arial,Helvetica,sans-serif;\'>";
                    strBody += BodyText + " </div>";

                    //(2) Assign the MailMessage's properties
                    mm.Subject = Subject;
                    mm.Body = strBody;
                    mm.IsBodyHtml = true;
                    mm.Priority = Priority;
                    if (RecipientList.Cc != string.Empty)
                    {
                        mm.CC.Add(RecipientList.Cc);
                    }
                    if (RecipientList.Bcc != string.Empty)
                    {
                        mm.Bcc.Add(RecipientList.Bcc);
                    }
                    if (Attachments != null)
                    {
                        foreach (Attachment attach in Attachments)
                        {
                            mm.Attachments.Add(attach);
                        }
                    }

                    //(3) Create the SmtpClient object
                    SmtpClient smtp = new SmtpClient();

                    bool RetrySend = true;
                    while (RetrySend)
                    {
                        try
                        {
                            smtp.Send(mm);
                        }
                        catch (SmtpFailedRecipientException ex)
                        {
                            switch (ex.StatusCode)
                            {
                                case SmtpStatusCode.MailboxBusy:
                                case SmtpStatusCode.TransactionFailed:
                                    continue;
                                default:
                                    break;
                            }
                        }
                        catch (SmtpException ex)
                        {
                            switch (ex.StatusCode)
                            {
                                case SmtpStatusCode.MailboxBusy:
                                case SmtpStatusCode.TransactionFailed:
                                    continue;
                                default:
                                    break;
                            }
                        }
                        catch (System.Exception)
                        {
                        }
                    }

                }

            }
            catch (System.Exception)
            {
            }
        }