public EmailReport(DamageConfiguration docConfig) { _glob = new Global(); _glob.UnlockBundle(@"SANTEC.CB1052020_sP5raFpzntnW"); _mailman = new MailMan(); _docConfig = docConfig; }
public static void RecordPartnerCallDelete(Guid userID, Guid partnerCallID, string reason, int numberOfPeople) { string message = String.Format("{0} deleted partnerCall[{1}] beacuse {2}, had [{3}] replies", UsersEmail, partnerCallID, reason, numberOfPeople); da.Insert(new LogEvent(userID, CFLogEventType.PartnerCallDelete, message)); MailMan.SendAppEventEmail(CFLogEventType.PartnerCallDelete, message, UsersEmail, userID, "*****@*****.**"); }
public FeedClimbingPost SaveFeedIntroductionPost(FeedClimbingPost newPost) { //-- Add that place to user's profile List <int> placeIDs = (from c in GetPlacesUserClimbs(newPost.UserID) select c.ID).ToList(); if (!placeIDs.Contains(newPost.PlaceID)) { SavePlaceUserClimbsAt(newPost.UserID, newPost.PlaceID); } //-- Save the post newPost.PostedDateTime = DateTime.Now; newPost.ClimbingDateTime = DateTime.Now; newPost.TagID = 52; FeedClimbingPost post = new FeedClimbingPostDA().Insert(newPost); //-- Send off notifications List <ClimberProfile> usersSubscribedToPlace = new ClimberProfileDA().GetPartnerEmailSubscribedUsers(newPost.PlaceID); Place place = CFDataCache.GetPlace(newPost.PlaceID); ClimberProfile poster = CFDataCache.GetClimberFromCache(newPost.UserID); foreach (ClimberProfile cp in usersSubscribedToPlace) { MailMan.SendFeedPostIntroductionNotificationEmail(cp, poster, post, place.Name); } //-- Subscribe them to this place too SubscribeToPartnerCallsByEmail(newPost.UserID, place.ID); return(post); }
public void ReplyToPartnerCall(Guid partnerCallID, Guid replyingUserID, string message) { PartnerCall call = new PartnerCallDA().GetByID(partnerCallID); if (call.CreatorUserID == replyingUserID) { throw new Exception(string.Format("You cannot reply to your own partner call. call[{0}]", call.ID)); } PartnerCallReply reply = new PartnerCallReplyDA().Insert(new PartnerCallReply { ID = Guid.NewGuid(), ReplyDateTime = DateTime.Now, ReplyingUserID = replyingUserID, PartnerCallID = partnerCallID, Message = message }); ClimberProfile poster = CFDataCache.GetClimberFromCache(call.ClimberProfileID); ClimberProfile replyer = CFDataCache.GetClimberFromCache(replyingUserID); MailMan.SendReplyToPartnerCall(call, reply, replyer, replyer.Email, poster.Email); CFLogger.RecordPartnerCallReply(replyingUserID, partnerCallID); }
public static void RecordException(Exception ex, string extraMSGContext) { Guid userID = new Guid(); string email = "anonymous"; if (HttpContext.Current.User.Identity.IsAuthenticated) { email = HttpContext.Current.User.Identity.Name; userID = new CFController().GetClimberProfileByEmail(email).ID; } MailMan.SendAppExceptionEmail(ex, email); LogExceptionEvent exceptionEvent = exDA.Insert( new LogExceptionEvent { Browser = HttpContext.Current.Request.Browser.Browser.ToString() + " v" + HttpContext.Current.Request.Browser.Version.ToString(), ExceptionDateTime = DateTime.Now, InnerMessage = extraMSGContext + ", " + ex.Message, IP = HttpContext.Current.Request.UserHostName.Take(15), //Try see if the length of this field is causing the truncated exception Url = HttpContext.Current.Request.Url.ToString(), UserEmail = email, Reviewed = false, UserID = userID, StackTrace = ex.StackTrace.ToString() }); string messsage = String.Format("{0} experienced exception[{1}]: {2}", UsersEmail, exceptionEvent.ID, ex.Message).Take(254); da.Insert(new LogEvent(userID, CFLogEventType.Exception, messsage.Take(254))); }
public FeedPostComment SaveFeedPostComment(FeedPostComment comment) { comment.PostedDateTime = DateTime.Now; FeedPostComment newComment = new FeedPostCommentDA().Insert(comment); FeedClimbingPost post = new FeedClimbingPostDA().GetByID(comment.FeedPostID); //-- Send notification to the poster FeedSettings postersFeedSettings = GetUsersFeedViewSettings(post.UserID); if (postersFeedSettings.NotifyOnPostComment && comment.UserID != post.UserID) { MailMan.SendCommentOnMyFeedPostNotification(post.ID, comment.User, post.User, comment.Message); } List <Guid> uniqueCommentingUserIDs = (from c in post.Comments where c.UserID != post.UserID select c.UserID).Distinct().ToList(); //-- Send notifications to other commentors foreach (Guid userID in uniqueCommentingUserIDs) { FeedSettings commentorsFeedSettings = GetUsersFeedViewSettings(userID); if (commentorsFeedSettings.NotifyOnPostsICommentedOn && comment.UserID != userID) { MailMan.SendCommentOnAFeedPostICommentedOnNotification(post.ID, comment.User, post.User, CFDataCache.GetClimberFromCache(userID), comment.Message); } } return(newComment); }
// tag::buildAndSendMail[] public void DoBuildAndSendMail(MailMan m, MailAddress mAddress, MailBody mBody) { // Build the mail Mail mail = new Mail(mAddress, mBody); // Send the mail m.SendMail(mail); }
// tag::buildAndSendMail[] public void DoBuildAndSendMail(MailMan m, MailAddress mAddress, MailBody mBody) { // Build the mail Mail mail = new Mail(mAddress, mBody); // Send the mail m.SendMail(mail); }
public static void RecordDeleteAccount(Guid userID, string fullName, string emailAddress) { string message = string.Format("{0}[{1}] deleted their account", fullName, emailAddress, userID); da.Insert(new LogEvent(userID, CFLogEventType.DeleteAccount, message)); foreach (string email in AdminsToRecieveRegistrationNotifications) { MailMan.SendAppEventEmail(CFLogEventType.DeleteAccount, message, emailAddress, userID, email); } }
public static void RecordRegistration(Guid userID, string emailAddress) { string message = string.Format("{0} registered, profile at http://cf3.climbfind.com/climber-profile/{1}", emailAddress, userID); da.Insert(new LogEvent(userID, CFLogEventType.Registration, message)); foreach (string email in AdminsToRecieveRegistrationNotifications) { MailMan.SendAppEventEmail(CFLogEventType.Registration, message, emailAddress, userID, email); } }
public static void RecordModerateDeletePlace(Guid userID, string placeName, int countryID, string placeUrl) { string message = string.Format("Deleted place {1}[c{2}] <a href='http://cf3.climbfind.com{3}'>http://cf3.climbfind.com{3}</a>", UsersEmail, placeName, countryID, placeUrl); da.Insert(new LogEvent(userID, CFLogEventType.ModerateDeletePlace, message)); foreach (string email in ModeratorsToRecievePlaceNotifications) { MailMan.SendAppEventEmail(CFLogEventType.ModerateDeletePlace, message, UsersEmail, userID, email); } }
public static void RecordModerateDeleteCrag(Guid userID, string cragName, string cragUrl) { string message = string.Format("Deleted crag {1} <a href='http://cf3.climbfind.com{2}'>http://cf3.climbfind.com{2}</a>", UsersEmail, cragName, cragUrl); da.Insert(new LogEvent(userID, CFLogEventType.ModerateDeleteCrag, message)); foreach (string email in ModeratorsToRecieveCragNotifications) { MailMan.SendAppEventEmail(CFLogEventType.ModerateDeleteCrag, message, UsersEmail, userID, email); } }
public void SendMessageBoardNotification(Guid recievingUserID, string message) { if (CurrentClimber.ID != recievingUserID) { ClimberProfile receiver = GetClimberProfile(recievingUserID); MailMan.SendMessageboardNotificationEmail(CurrentClimber, receiver, message); } //CFLogger.re //-- ToDO: consider logging message post. }
public void SendClimberWatchRequest(Guid watchedUserID, Guid watchingUserID) { FeedClimberChannelRequest watchedClimberEntry = new FeedClimberChannelRequestDA().Insert( new FeedClimberChannelRequest() { WatchedUserID = watchedUserID, WatchingUserID = watchingUserID, RequestedDateTime = DateTime.Now }); MailMan.SendWatchRequestEmail(watchedClimberEntry.ID, CFDataCache.GetClimberFromCache(watchingUserID), CFDataCache.GetClimberFromCache(watchedUserID)); }
// tag::buildAndSendMail[] public void DoBuildAndSendMail(MailMan m, string firstName, string lastName, string division, string subject, MailFont font, string message1, string message2, string message3) { // Format the email address string mId = firstName[0] + "." + lastName.Substring(0, 7) + "@" + division.Substring(0, 5) + ".compa.ny"; // Format the message given the content type and raw message MailMessage mMessage = FormatMessage(font, message1 + message2 + message3); // Send message m.Send(mId, subject, mMessage); }
public void DoBuildAndSendMail(MailMan m, Mail mail) { // Format the email address string mId = $"{mail.firstName[0]}.{mail.lastName.Substring(0, 7)}" + $"@{mail.division.Substring(0, 5)}.compa.ny"; // Format the message given the content type and raw message MailMessage mMessage = FormatMessage(mail.font, mail.message1 + mail.message2 + mail.message3); // Send message m.Send(mId, mail.subject, mMessage); }
/// <summary> /// Override TraceData to hook in our custom behavior. I.e. only take notice if we're tracing an exception that has a trace code of /// ESBExcepction /// </summary> /// <param name="eventCache"></param> /// <param name="source"></param> /// <param name="eventType"></param> /// <param name="id"></param> /// <param name="data"></param> public override void TraceData(TraceEventCache eventCache, string source, TraceEventType eventType, int id, object data) { if (id != (int)TraceCode.Exception) { return; } if (data is Exception) { var ex = data as Exception; MailMan.SendAppException(ex); } }
public static void SaveFeedback(Guid userID, string comment) { ClimberProfile climberProfile = new ClimberProfileDA().GetByID(userID); new FeedbackDA().Insert(new Feedback { DateTimePosted = DateTime.Now, UserID = userID, FeedbackFromUser = comment, ResponseFromAdmin = "" }); MailMan.SendFeedbackAlertEmail(climberProfile.Email, climberProfile.FullName, comment); }
private void SendPartnerCallNotificationEmails(PartnerCall call, List <int> placeIDs) { Dictionary <ClimberProfile, int> usersSubscribedToAtLeastOnePlace = new ClimberProfileDA().GetPartnerCallEmailSubscribedUsers(placeIDs); foreach (ClimberProfile cp in usersSubscribedToAtLeastOnePlace.Keys) { if (cp.Email != User.Name) { Place place = CFDataCache.GetPlace(usersSubscribedToAtLeastOnePlace[cp]); MailMan.SendPartnerCallNotificationEmail(cp, call, place.Name, call.PlacesNamesString, cp.Email); } } }
// tag::buildAndSendMail[] public void DoBuildAndSendMail(MailMan m, string firstName, string lastName, string division, string subject, MailFont font, string message1, string message2, string message3) { // Format the email address string mId = $"{firstName[0]}.{lastName.Substring(0, 7)}" + $"@{division.Substring(0, 5)}.compa.ny"; // Format the message given the content type and raw message MailMessage mMessage = FormatMessage(font, message1 + message2 + message3); // Send message m.Send(mId, subject, mMessage); }
/// <summary> /// /// </summary> /// <param name="message"></param> public void ProcessCommentWorkItem(CommentAlertWorkItem comment) { var post = new PostRepository().GetByID(comment.PostID); var userIDsOnThread = post.PostComments.Where(pc => pc.UserID != comment.ByID).Select(pc => pc.UserID).Distinct().ToList(); var by = CfPerfCache.GetClimber(comment.ByID); var excerpt = comment.Content; if (excerpt.Length > 30) { excerpt = excerpt.Substring(0, 30); } var msg = string.Format("<a href='/climber/{0}'>{1}</a> made a <a href='/post/{2}'>comment</a><i> \"{3}...\"</i></a>", by.ID, by.DisplayName, comment.PostID, excerpt); //-- Also need to let the person who posted know incase they haven't commented on their own post or already part of the commentors if (by.ID != post.UserID && !userIDsOnThread.Contains(post.UserID)) { userIDsOnThread.Add(post.UserID); } foreach (var uID in userIDsOnThread) { var settings = GetUserSiteSettings(uID); if (settings.CommentsOnPostsAlertFeed || settings.CommentsOnPostsEmailRealTime || settings.CommentsOnPostsMobileRealTime) { var toUser = CfPerfCache.GetClimber(uID); var a = new Alert() { ID = Guid.NewGuid(), Utc = DateTime.UtcNow, TypeID = (byte)AlertType.CommentOnPost, UserID = toUser.ID, Message = msg }; if (settings.CommentsOnPostsAlertFeed) { a.ByFeed = true; } if (settings.CommentsOnPostsEmailRealTime) { a.ByEmail = true; MailMan.SendCommentEmail(toUser, by, comment.PostID, comment.Content); } if (settings.CommentsOnPostsMobileRealTime && !string.IsNullOrEmpty(settings.DeviceTypeRegistered)) { a.ByMobile = true; MobilePush_CommentAlert(comment.PostID, by.DisplayName, toUser.Email, settings.DeviceTypeRegistered); } new AlertRepository().Create(a); } } }
public void SendMessage(ClimberProfile receiver, string subject, string message) { UserMessage msg = new UserMessageDA().Insert( new UserMessage { ID = Guid.NewGuid(), ReceivingUserID = receiver.ID, SendingUserID = CurrentClimber.ID, Subject = subject, SentDateTime = DateTime.Now, Message = message }); MailMan.SendUserMessageEmail(CurrentClimber, receiver, subject, message, msg.ID); }
public FeedClimbingPost SaveFeedPost(FeedClimbingPost newPost) { newPost.PostedDateTime = DateTime.Now; FeedClimbingPost post = new FeedClimbingPostDA().Insert(newPost); List <ClimberProfile> usersSubscribedToPlace = new ClimberProfileDA().GetPartnerEmailSubscribedUsers(newPost.PlaceID); Place place = CFDataCache.GetPlace(newPost.PlaceID); ClimberProfile poster = CFDataCache.GetClimberFromCache(newPost.UserID); foreach (ClimberProfile cp in usersSubscribedToPlace) { MailMan.SendPartnerFeedPostNotificationEmail(cp, poster, post, place.Name); } return(post); }
/// <summary> /// /// </summary> /// <param name="message"></param> public void ProcessMessageWorkItem(MessageAlertWorkItem message) { var settings = GetUserSiteSettings(message.ToID); if (settings.MessagesAlertFeed || settings.MessagesEmailRealTime || settings.MessagesMobileRealTime) { var excerpt = message.Content; if (excerpt.Length > 30) { excerpt = excerpt.Substring(0, 30); } var from = CfPerfCache.GetClimber(message.FromID); var msg = string.Format("<a href='/climber/{0}'>{1}</a> sent you a <a href='/message/{0}'>Message</a><i> \"{2}...\"</i></a>", from.ID, from.DisplayName, excerpt); //-- Not sure why PostID is neccessary.... hmmmmmm var a = new Alert() { ID = Guid.NewGuid(), Utc = DateTime.UtcNow, TypeID = (byte)AlertType.Message, UserID = message.ToID, Message = msg }; if (settings.MessagesAlertFeed) { a.ByFeed = true; } if (settings.MessagesEmailRealTime) { a.ByEmail = true; MailMan.SendUserMessageEmail(CfPerfCache.GetClimber(message.ToID), from, message.Content); } if (settings.MessagesMobileRealTime && !string.IsNullOrEmpty(settings.DeviceTypeRegistered)) { a.ByMobile = true; MobilePush_MessageAlert(from.DisplayName, CfPerfCache.GetClimber(message.ToID).Email, settings.DeviceTypeRegistered); } new AlertRepository().Create(a); } }
/// <summary> /// /// </summary> /// <param name="dto"></param> public void ProcessPartnerCallWorkItem(PartnerCallAlertWorkItem dto) { IfNullThrowArgumentExceptionAndClearMsg(dto, "Cannot process PartnerCallAlertWorkItem, dto object is null.", ""); var pc = pcRepo.GetByID(dto.PartnerCallID); IfNullThrowArgumentExceptionAndClearMsg(pc, "Cannot process PartnerCallAlertWorkItem[{0}], PartnerCall is null.", dto.ToJson()); var post = new PostRepository().GetByID(pc.ID); if (post == null) { pcRepo.Delete(pc.ID); return; } //-- If they've deleted the post, let's not send out anything and delete the original call... var place = AppLookups.GetCacheIndexEntry(pc.PlaceID); //if (place == null) //-- Maybe we tried to read when //{ // //} IfNullThrowArgumentExceptionAndClearMsg(place, "Cannot process PartnerCallAlertWorkItem[{0}] for place[{1}], Place is null.", pc.ID, pc.PlaceID); var by = CfPerfCache.GetClimber(pc.UserID); IfNullThrowArgumentExceptionAndClearMsg(by, "Cannot process PartnerCallAlertWorkItem[{0}] for byUser[{1}], User is null.", pc.ID, pc.UserID); PCNWorkItem pcnWi = new PartnerCallNotificationWorkItem() { ID = Guid.NewGuid(), CreatedUtc = DateTime.UtcNow, CountryID = place.CountryID, OnBehalfOfUserID = by.ID, PartnerCallID = pc.ID, PlaceID = pc.PlaceID }; var alerts = new List <Alert>(); var msg = string.Format("<a href='/climber/{0}'>{1}</a> posted a <a href='/partner-call/{2}'>PartnerCall™</a> for <a href='{3}'>{4}</a>", by.ID, by.DisplayName, pc.ID, place.SlugUrl, place.Name); var deduciblePlaces = CfPerfCache.GetGeoDeduciblePlaces(place); var subscriptionsByUsers = pcsRepo.GetSubscriptionsForPlaces(deduciblePlaces.Select(p => p.ID).ToList()) .Where(s => s.UserID != pc.UserID).GroupBy(s => s.UserID); //-- We only want to create one Alert per user for a single partner call foreach (var subsUserSet in subscriptionsByUsers) { try { var subscribedUser = CfPerfCache.GetClimber(subsUserSet.Key); if (subscribedUser == null) { throw new ArgumentException(string.Format("Cannot process partner call subscription alerts for user[{0}] as user is null", subsUserSet.Key)); } var matchingSubs = new List <PCSubscription>(); foreach (var sub in subsUserSet) { if (sub.PlaceID == place.ID || !sub.ExactMatchOnly) //-- Here we make sure we don't include subscription with ExactMatchOnly chosen { //-- Make sure we match on Indoor/Outdoor preferences if ((sub.ForIndoor && pc.ForIndoor) || (sub.ForOutdoor && pc.ForOutdoor)) { matchingSubs.Add(sub); } } } if (matchingSubs.Count > 0) { var alert = new Alert() { ID = Guid.NewGuid(), Utc = DateTime.UtcNow, TypeID = (byte)AlertType.PartnerCall, PostID = pc.ID, UserID = subscribedUser.ID, Message = msg }; alert.ByFeed = true; //-- Here we always put partner calls in the alert feed (unless at a later date we decide to change this). //-- Default notifications bool sendEmail = false; bool sendMobilePush = false; int count = 1; string subscriptionPlaces = string.Empty; foreach (var sub in matchingSubs) { if (sub.EmailRealTime) { sendEmail = true; } if (sub.MobileRealTime) { sendMobilePush = true; } var p = AppLookups.GetCacheIndexEntry(sub.PlaceID); if (count == 1) { subscriptionPlaces = p.Name; } else if (count == matchingSubs.Count) { alert.Message += string.Format(" & {0}", p.Name); } else { alert.Message += string.Format(", {0}", p.Name); } count++; } if (matchingSubs.Count == 1) { alert.Message += ", <i>matching subscription for " + subscriptionPlaces + ".</i>"; } else { alert.Message += ", <i>matching subscriptions for " + subscriptionPlaces + ".</i>"; } if (sendEmail) { MailMan.SendPartnerCallEmail(subscribedUser, by, place, pc, subscriptionPlaces); alert.ByEmail = true; } //if (sendMobilePush) //{ //SendAlertByMobilePush(alert); // alert.ByMobile = true; //} alerts.Add(alert); } } catch (Exception ex) // Here we have a try catch incase it fails for one user we can try and still process the others { CfTrace.Error(ex); } } pcnWi.NotificationsSent = alerts.Count(); pcnWi.ProcessedUtc = DateTime.UtcNow; pcWRepo.Create(pcnWi); //-- We have to check this again to see if they delete the post while we were processing var postagain = new PostRepository().GetByID(pc.ID); if (postagain != null) { new AlertRepository().Create(alerts); } CfTrace.Information(TraceCode.PartnerCallNofiticatonWorkItemProcess, "Processed {4} <a href='/climber/{0}'>{1}'s</a> <a href='/partner-call/{2}'>PartnerCall™</a> for {3}.", by.ID, by.DisplayName, pc.ID, place.Name, alerts.Count); }
private static bool SentMessage(string hostSMTP, int portSMTP, bool sslSMTP, string username, string password, Email Mail) { MailMan smtp = new MailMan(); if (!(smtp.UnlockComponent("MAIL-TEAMBEAN_4895F76A292K"))) return false; smtp.SmtpHost = hostSMTP; smtp.SmtpPort = portSMTP; smtp.SmtpUsername = username; smtp.SmtpPassword = password; Mail.Charset = "utf-8"; if (sslSMTP) smtp.PopSsl = true; //SSL support else smtp.PopSsl = false; //connect without SSL support if (smtp.SendEmail(Mail)) return true; else return false; }
// POP3: Get all messages in server (HostPOP) and after that, delete all od messages in that server public int GetMailPOPDelete(string FolderName, string HostPOP, int PortPOP, bool SSLSupport, string MailName, string PWstring) { if (!imapConnect()) return -1; //choose current folfer if (!imapClient.SelectMailbox(FolderName)) { // if folder is not exist, create new folder imapClient.CreateMailbox(FolderName); imapClient.SelectMailbox(FolderName); } MessageSet OLdMSSet = imapClient.Search("ALL", true); MailMan subpopClient = new MailMan(); if (!subpopClient.UnlockComponent("MAIL-TEAMBEAN_4895F76A292K")) return -1; // config info of pop server subpopClient.MailHost = HostPOP; subpopClient.MailPort = PortPOP; subpopClient.PopUsername = MailName; subpopClient.PopPassword = PWstring; if (SSLSupport) subpopClient.PopSsl = true; //SSL support else subpopClient.PopSsl = false; //connect without SSL support subpopClient.ConnectTimeout = 15; // defaulf timeout = 30, so when it can't connect, it's too slow EmailBundle colecMessageInfo = subpopClient.CopyMail(); //Copy all of mail in mailbox of pop server if (colecMessageInfo == null) //connect fail, or don't have any new message { imapDisconnect(); return -1; } else { //copy new message to folder on our server for (int i = 0; i < colecMessageInfo.MessageCount; i++) { Email msif = colecMessageInfo.GetEmail(i); imapClient.AppendMail(FolderName, msif); } } subpopClient.DeleteBundle(colecMessageInfo); //delete all messages on pop server // mark new message unread // it's a little complex here, contact me if you need support imapClient.SelectMailbox(FolderName); MessageSet NewMSSet = imapClient.Search("ALL", true); for (int i = 0; i < OLdMSSet.Count; i++) NewMSSet.RemoveId(OLdMSSet.GetId(i)); imapClient.SetFlags(NewMSSet, "Seen", 0); imapDisconnect(); return colecMessageInfo.MessageCount; }
//connect to Mail server throught POP3 public static bool TestPopConnect(string host, int port, string username, string password, ref string error) { popClient = new MailMan(); if (!popClient.UnlockComponent("MAIL-TEAMBEAN_4895F76A292K")) return false; popClient.MailHost = host; popClient.MailPort = port; popClient.PopUsername = username; popClient.PopPassword = password; if (SSL) popClient.PopSsl = true; else popClient.PopSsl = false; if (!popClient.VerifyPopConnection()) { error = "Server"; return false; } if (!popClient.VerifyPopLogin()) { error = "Account"; return false; } return true; }
//Sent message local public static bool SentMessage(Email Mail) { MailMan smtp = new MailMan(); if (!(smtp.UnlockComponent("MAIL-TEAMBEAN_4895F76A292K"))) return false; if (!Connect.SetConfigInfo()) return false; if (UserName == null) { UserName = FrameworkParams.currentUser.username + "@" + Connect.domain; Password = FrameworkParams.currentUser.id + "_protocolvn"; } smtp.SmtpHost = HostSMTP; smtp.SmtpPort = PortSMTP; smtp.SmtpUsername = AccountLogin(UserName); smtp.SmtpPassword = Password; Mail.From = UserName; if (SSLSMTP) smtp.PopSsl = true; //SSL support else smtp.PopSsl = false; //connect without SSL support if (smtp.SendEmail(Mail)) return true; else return false; }
/// <summary> /// User the users' messageboardID as theverification mechanism /// </summary> public void SendVerifyEmailAddressEmail(ClimberProfile cp) { cp.EmailVerificationSent = true; new ClimberProfileDA().Update(cp); MailMan.SendVerifyEmailAddressEmail(cp); }
void ServiceHost_RefreshNotificationRecieved(object sender, RefreshMessage e) { MailMan.SendAppEvent(TraceCode.AppBuildCache, "Receive refresh request notification, refreshing cache server", "*****@*****.**", Guid.Empty, "*****@*****.**", false); PopuluteCfCacheIndex(); }
void MemcachedServer_Crashed(object sender, EventArgs e) { MailMan.SendAppEvent(TraceCode.AppEnd, "Memcached server failed!! Recycling cf.CacheServer worker role", "*****@*****.**", Stgs.SystemID, "*****@*****.**", false); RoleEnvironment.RequestRecycle(); }
/// <summary> /// Process the new lead emails. /// </summary> /// <returns>True if it worked.</returns> private bool ProcessIncomingLeadEmails() { Log("Gettting email leads..."); string msg = string.Empty; MailMan mailman = ApplicationManager.GetLeadMailman(); bool result = false; int nonLeadEmails = 0; int duplicateEmails = 0; int successfulWrites = 0; int failedWrites = 0; int bouncedEmails = 0; if (mailman != null) { Log("Getting all emails..."); EmailBundle leadEmails = ApplicationManager.GetLeadEmails(mailman, out msg); if (leadEmails != null) { Log("Found {0} emails.", leadEmails.MessageCount); int i; Email email = null; for (i = 0; i <= leadEmails.MessageCount - 1; i++) { email = leadEmails.GetEmail(i); Lead lead = ApplicationManager.GetLeadFromFundraisingIdeasEmail(email); bool deleteThisEmail = false; if (lead != null) { Log("Retrieved lead: {0}", lead.ToString()); Lead existingLead = DataManager.GetLead(lead.EmailAddress); bool res = false; if (existingLead == null) { // res = DataManager.WriteLead(lead, DataManager.ObjectWriteMode.Insert); res = DataManager.WriteCustomer(lead, DataManager.ObjectWriteMode.Insert); Log("Write lead to db: {0}", res.ToString()); if (res) { successfulWrites++; } else { failedWrites++; throw new ApplicationException("Cannot write lead to db - cannot continue"); } } else { Log("Lead exists in db, skipping..."); duplicateEmails++; } if (existingLead != null || res) { // Its either a duplicate, or it was inserted ok, either way let's delete it. deleteThisEmail = true; } } else if (email.From.Contains("Mail Delivery Subsystem")) { // // We have a bounced email // string bounceEmail = Functions.GetValueFromText(email.Body, "<(.*@.*)>"); string bounceReason = Functions.GetValueFromText(email.Body, "<.*@.*>...(.*)"); if (bounceReason == string.Empty) { bounceReason = Functions.GetValueFromText(email.Body, "\\((reason.*55.*)\\)"); } if (bounceEmail != string.Empty) { Lead existingLead = DataManager.GetLead(bounceEmail); // email.GetAttachedMessage(0).GetToName(0) if (existingLead == null) { // // No email address, let's try by name and status // if (email.NumAttachedMessages > 0 && email.GetAttachedMessage(0).NumTo > 0) { PersonName name = new PersonName(); if (name.ParseFullName(email.GetAttachedMessage(0).GetToName(0))) { existingLead = DataManager.GetLeadByNameAndStatus(name.FirstName, name.LastName, Lead.LeadStatusCode.lscEmailSent); } } } if (existingLead != null) { bool res = DataManager.WriteLeadStatusLog(existingLead, Lead.LeadStatusCode.lscEmailBounced1, bounceReason.Substring(0, Math.Min(150, bounceReason.Length))); Log("Bounced email from {0} for reason \"{1}\", update status log = {2}", bounceEmail, bounceReason, res); if (res) { deleteThisEmail = true; } } else { Log("Bounced email from {0}, but can't find email addr in db.", bounceEmail); } } else { Log("We have a bounced email, but can't get the email address from the body."); } bouncedEmails++; } else if (email.Subject.Contains("Out of Office") || email.Subject.Contains("AutoReply")) { Log("Found autoreply from: {0}, deleting", email.From); deleteThisEmail = true; } else if (email.Subject == "echo") { Log("Found echo request from: {0}", email.FromAddress); Lead testLead = new Lead(); testLead.ParseFullName(email.FromName); testLead.LeadInfoText = email.GetPlainTextBody(); testLead.EmailAddress = email.FromAddress; ApplicationManager.SetFundraisingIdeasProperties(testLead); if (testLead.TemplateCurrent == null) { testLead.TemplateCurrent = DataManager.GetTemplate("Hockey"); // Hockey template } ProcessNewDatabaseLeads(testLead); deleteThisEmail = true; } else if (email.Subject == "unsubscribe") { Log("Found unsubscribe request from: {0}", email.FromAddress); Lead existingLead = DataManager.GetLead(email.FromAddress); if (existingLead != null) { bool res = DataManager.WriteLeadStatusLog(existingLead, Lead.LeadStatusCode.lscUnsubscribeRequestReceived); Log("Bye bye {0}; update status log = {1}", existingLead.FirstName, res); if (res) { deleteThisEmail = true; } } else { Log("Odd, can't find email address in db. Doing nothing."); } } else { Log("Skipping non-lead email from: {0}", email.FromAddress); nonLeadEmails++; } if (deleteThisEmail) { // Delete this email. bool success = mailman.DeleteEmail(email); if (success != true) { Log("Strangeness, can't delete POP3 email: {0}", mailman.LastErrorText); } } } Log("Ending email session..."); mailman.Pop3EndSession(); Log("Summary - total emails found: {0}, non-lead: {1}, duplicate: {2}, newly inserted: {3}", leadEmails.MessageCount, nonLeadEmails, duplicateEmails, successfulWrites); result = true; } else { // // Happens if tcp/ip issue. Thanks Time Warner! // Log("Can't get POP3 emails. Msg was: {0}", msg); } } else { Log("Can't get mailman component - is it registered and licensed?"); } return(result); }
/// <summary> /// Used: /// 1) In the case when the facebook ID does not match a profile, but the user is signed in to facebook (we check if we can connect the accounts) /// 2) When the user logs in with their CF3 email/password to a client (Accounts Server, PG Site, CF4, Mobile App) for the first time /// </summary> public Profile GetUserByEmailAndCreateCf4ProfileIfNotExists(string email) { var profile = profileRepo.GetProfileByEmail(email); if (profile == null) { var cf3Profile = new cf.DataAccess.cf3.ClimberProfileDA().GetClimberProfile(email); if (cf3Profile != default(Cf3Profile)) { var idStr = cf3Profile.ID.ToString(); string userName = idStr.Substring(idStr.Length - 9, 8); profile = new Profile() { ID = cf3Profile.ID, CountryID = byte.Parse(cf3Profile.Nationality.ToString()), DisplayNameTypeID = 0, Email = email, FullName = cf3Profile.FullName, IsMale = cf3Profile.IsMale.Value, NickName = cf3Profile.NickName, UserName = userName, ContactNumber = cf3Profile.ContractPhoneNumber, PrivacyAllowNewConversations = true, PrivacyShowFeed = true, PrivacyShowHistory = true, PrivacyPostsDefaultIsPublic = true, PrivacyShowInSearch = true, PrivacyShowOnPartnerSites = true }; profileRepo.Create(profile); var traceMsg = string.Format("{0} upgraded cf3 account", cf3Profile.FullName); CfTrace.Information(TraceCode.UserCreateAccount, traceMsg); MailMan.SendAppEvent(TraceCode.UserCreateAccount, traceMsg, email, cf3Profile.ID, "*****@*****.**", true); try { var originalImgUrl = GetCf3ProfilePicFullSizeUrl(cf3Profile.ID, cf3Profile.ProfilePictureFile); if (!string.IsNullOrWhiteSpace(originalImgUrl)) { using (Stream imgStream = new ImageDownloader().DownloadImageAsStream(originalImgUrl)) { if (imgStream == null) { throw new ArgumentException("Cf3 image stream is null for: " + originalImgUrl); } if (profile == null) { throw new ArgumentException("Profile is null..."); } //-- Note this function automatically updates the user object in the database SaveProfileAvatarPicFrom3rdPartSource(imgStream, profile); } } } catch (Exception ex) { CfTrace.Error(ex); } } } return(profile); }
public static bool smtpAuthentication(string hostSMTP, int portSMTP, string userName, string password) { MailMan smtpTest = new MailMan(); smtpTest.SmtpHost = hostSMTP; smtpTest.SmtpPort = portSMTP; smtpTest.SmtpUsername = userName; smtpTest.SmtpPassword = password; if (SSL) smtpTest.PopSsl = true; else smtpTest.PopSsl = false; Email mail = new Email(); mail.From = userName; mail.AddTo("", userName); mail.Subject = "Test mail"; mail.SetHtmlBody("<html><body><b><font color='red' size='+1'>Thư kiểm tra</font></b></html>"); if (smtpTest.SendEmail(mail)) return true; else return false; }
/// <summary> /// Called from authenticated facebook client 'accounts.climbfind.com' and the mobile app /// </summary> /// <param name="email"></param> /// <param name="fullName"></param> /// <param name="password"></param> /// <param name="nationality"></param> /// <param name="isMale"></param> /// <param name="facebookID"></param> /// <param name="facebookToken"></param> /// <param name="signUpOrigin"></param> /// <returns></returns> public Profile CreateUser(string email, string fullName, string password, byte nationality, bool isMale, long?facebookID, string facebookToken, string signUpOrigin) { try { bool detailsValid = true; //-- todo, perform some sort of validation on incoming details if (detailsValid) { MembershipCreateStatus createStatus; var mUser = Membership.CreateUser(email, password, email, null, null, true, null, out createStatus); if (createStatus != MembershipCreateStatus.Success) { throw new MembershipCreateUserException(createStatus); } else { var userID = new Guid(mUser.ProviderUserKey.ToString()); var user = CreateProfile(new Profile() { ID = userID, CountryID = nationality, Email = email, FullName = fullName, IsMale = isMale, FacebookID = facebookID, FacebookToken = facebookToken, PrivacyAllowNewConversations = true, PrivacyShowFeed = true, PrivacyShowHistory = true, PrivacyPostsDefaultIsPublic = true, PrivacyShowInSearch = true, PrivacyShowOnPartnerSites = true }); var traceMsg = string.Format("{0} created an account via {1}", fullName, signUpOrigin); if (facebookID.HasValue) { traceMsg += " w fbid: " + facebookID.Value.ToString(); } CfTrace.Information(TraceCode.UserCreateAccount, traceMsg); MailMan.SendAppEvent(TraceCode.UserCreateAccount, traceMsg, email, userID, "*****@*****.**", true); try { if (facebookID.HasValue) { var originalImgUrl = string.Format("http://graph.facebook.com/{0}/picture?type=large", facebookID.Value); using (Stream imgStream = new ImageDownloader().DownloadImageAsStream(originalImgUrl)) { //-- Note this function automatically updates the user object in the database SaveProfileAvatarPicFrom3rdPartSource(imgStream, user); } } } catch (Exception ex) { CfTrace.Error(ex); } return(user); } } else { throw new Exception("Sign up detail invalid from origin: " + signUpOrigin); } } catch (Exception ex) //-- extra logging / safety as we really don't want this code to screw up and if it does be better know about it! { if (!ex.Message.Contains("form required for an e-mail address") && !ex.Message.Contains("username is already in use")) { CfTrace.Error(ex); } throw ex; } }
public static void ScanGmail(string[] strings, Types type) { Console.WriteLine("VER 3"); Bounce b = new Bounce(); b.UnlockComponent("DONTSTAYINBOUNCE_OS2MBg0e7GpB"); MailMan mailman = new MailMan(); mailman.UnlockComponent("DONTSTAYINMAILQ_5CHEZpZc7Gp9"); //mailman.ConnectTimeout = 5; mailman.MailPort = 995; mailman.PopSsl = true; mailman.MailHost = "pop.gmail.com"; if (type == Types.DontStayIn) { Console.WriteLine("*****@*****.**"); mailman.PopUsername = "******"; mailman.PopPassword = "******"; } else if (type == Types.Mixmag) { Console.WriteLine("*****@*****.**"); mailman.PopUsername = "******"; mailman.PopPassword = "******"; } else if (type == Types.SpamTrap) { Console.WriteLine("*****@*****.**"); mailman.PopUsername = "******"; mailman.PopPassword = "******"; } // Copy the mail into a bundle object. The mail still remains // on the POP3 server. Call TransferMail to copy and remove // mail from the POP3 server. Chilkat.EmailBundle bundle; Console.WriteLine("Getting bundle..."); List<string> emailAddresses = new List<string>(); int ignored = 0; int ignoredHard = 0; int hardBounces = 0; int exceptions = 0; int total = 0; // Loop over each email and save attachments. // Also add the email subject to a list box. do { emailAddresses = new List<string>(); ignored = 0; ignoredHard = 0; hardBounces = 0; exceptions = 0; total = 0; bundle = mailman.CopyMail(); Console.WriteLine("Got {0} messages", bundle.MessageCount.ToString()); total = bundle.MessageCount; int i; for (i = 0; i < bundle.MessageCount; i++) { Chilkat.Email email = bundle.GetEmail(i); try { Console.Write("."); if (type == Types.SpamTrap) { #region spam trap if (email.Subject == "complaint about message from 84.45.14.32") { bool isEflyer = false; bool isUpdateEmail = false; string fullBody = email.Body; string recipient = ""; string subject = ""; //Console.WriteLine(fullBody.Length > 4096 ? fullBody.Substring(0, 4096) : fullBody); //Console.ReadLine(); if (fullBody.IndexOf("From: [email protected]\r", StringComparison.OrdinalIgnoreCase) == -1) { isEflyer = true; } if (fullBody.IndexOf("Subject: DontStayIn this week", StringComparison.OrdinalIgnoreCase) > -1 || fullBody.IndexOf("Subject: Don't Stay In this week", StringComparison.OrdinalIgnoreCase) > -1) { isUpdateEmail = true; } { string firstLine = fullBody.Substring(0, fullBody.IndexOf("\r")); recipient = firstLine.Substring(firstLine.IndexOf(" ") + 1); } { string subjectAndOn = fullBody.Substring(fullBody.IndexOf("\r\nSubject: ", StringComparison.OrdinalIgnoreCase) + 11); subject = subjectAndOn.Substring(0, subjectAndOn.IndexOf("\r")); } Console.WriteLine("Email: {0}, Eflyer: {1}, UpdateEmail: {2}, Subject: {3}", recipient, isEflyer, isUpdateEmail, subject.Length > 30 ? subject.Substring(0,30) : subject); UsrSet us = new UsrSet(new Query(new Q(Usr.Columns.Email, recipient))); if (us.Count > 0) { foreach (Usr u in us) { if (isEflyer) { u.SendFlyers = false; } else if (isUpdateEmail) { u.SendSpottedEmails = false; } else { u.EmailHold = true; } u.Update(); } } } else Console.WriteLine("(not complaint email)"); #endregion } else { b.ExamineEmail(email); dealWithBounce(strings, b, "", ref hardBounces, ref ignoredHard, ref ignored); } } catch (Exception ex) { Console.WriteLine("EXCEPTION"); //Console.WriteLine(ex.Message); //throw ex; exceptions++; } //Console.WriteLine(""); //if (i < 10 || i % 10 == 0) // Console.WriteLine("Processed: " + i.ToString("#,##0") + " / " + total.ToString("#,##0") + ", bounces: " + hardBounces.ToString("#,##0") + ", ignored: " + ignored.ToString("#,##0") + ", ignoredHard: " + ignoredHard.ToString("#,##0") + ", errors: " + exceptions.ToString("#,##0")); } } while (total >= 250); }