コード例 #1
0
ファイル: Mailer.cs プロジェクト: 0huah0/csharp-samples
 public bool SendEmail(string username, string password, string subject, string fromaddress, string toaddress, string cc, string bcc, string body, bool isbodyhtml, string smtp)
 {
     if (username == ConfigurationManager.AppSettings["mailserviceuser"]
         && password == ConfigurationManager.AppSettings["mailservicepwd"])
     {
  
         HarperLINQ.SimpleMail mail = new SimpleMail();
         try
         {
             mail.bccemail = bcc;
             mail.body = body;
             mail.ccemail = cc;
             mail.datecreated = DateTime.Now;
             mail.fromemail = fromaddress;
             mail.isHtml = isbodyhtml;
             mail.ishtml = isbodyhtml;
             mail.smtpAddress = smtp;
             mail.subject = subject;
             mail.toemail = toaddress;
             using (AHT_MainDataContext context = new AHT_MainDataContext(ConfigurationManager.ConnectionStrings["AHT_MainConnectionString"].ConnectionString))
             {
                 context.SimpleMails.InsertOnSubmit(mail);
                 context.SubmitChanges();
             }
             return true;
         }
         catch
         {
             return false;
         }
     }
     else { return false; }
 }
コード例 #2
0
ファイル: Reminder.cs プロジェクト: 0huah0/csharp-samples
        public void Run()
        {
            try
            {
                List<HarperLINQ.Referral> referrals = Referral.GetNeedsReminderList();
                foreach (Referral referral in referrals)
                {
                    tbl_Customer member = new tbl_Customer(referral.memberid, false);
                    string cc = null;
                    if (referral.ccmember)
                    {
                        cc = member.cusEmail;
                    }

                    ReferralOffer offer = new ReferralOffer(referral.keycode, referral.pubcode);
                    string membername = string.Format("{0} {1}", member.cusFirstName, member.cusLastName);
                    string link = string.Format("{0}/Referral/Redeem.aspx?ReferralId={1}", ConfigurationManager.AppSettings["server"], System.Web.HttpUtility.UrlEncode(HarperCRYPTO.Cryptography.EncryptData(referral.id.ToString())));
                    string emailbody = offer.reminderemailcopy.Replace("[membername]", membername).Replace("[friendname]", referral.friendname).Replace("[link]", link);

                    SimpleMail reminder = new SimpleMail(offer.reminderemailsubject,
                                                        offer.reminderemailfromaddress,
                                                        referral.friendemail,
                        //"*****@*****.**",
                                                        string.Empty, //do not cc the reminders?
                                                        offer.reminderemailbcc,
                                                        emailbody,
                                                        offer.reminderemailishtml.HasValue ? offer.reminderemailishtml.Value : true,
                                                        offer.reminderemailsmtp);
                    reminder.Save();
                    referral.reminderemailid = reminder.id;
                    referral.Save();
                }
            }
            catch (Exception ex)
            {
                string SourceName = "ReferralReminder";
                if (!EventLog.SourceExists(SourceName))
                {
                    EventLog.CreateEventSource(SourceName, "Application");
                }

                EventLog eventLog = new EventLog();
                eventLog.Source = SourceName;
                string message = string.Format("Exception: {0} \n\nStack: {1}", ex.Message, ex.StackTrace);
                eventLog.WriteEntry(message, EventLogEntryType.Error);
            }
        }
コード例 #3
0
 partial void UpdateSimpleMail(SimpleMail instance);
コード例 #4
0
 partial void DeleteSimpleMail(SimpleMail instance);
コード例 #5
0
 partial void InsertSimpleMail(SimpleMail instance);