public static bool SendEmail(string email, string subject, string body, string from = "*****@*****.**") { var dce = new EmailServerContext(); if (Utilities.EmailValidator.Validate(email) && !String.IsNullOrEmpty(email)) { dce.EmailServer.Add(new EmailSendItem(EmailPriority.Normal) { //Body = body, Reciever = email, Subject = subject }); } dce.SaveChanges(); return true; }
internal static string PullLatestEmailMessage() { var dc = new EmailServerContext(); var message = dc.EmailMessages.OrderByDescending(x => x.EmailId).FirstOrDefault(); if (message != null) return message.Message; return string.Empty; }
public static void AddExceptionEmails(ErrorObject errorObject) { try { var dc = new EmailServerContext(); var databaseError = new DataModels.Exception.Exception { AdditionalInformation = errorObject.AdditionalInformation, AssemblyName = errorObject.AssemblyName, AssemblyVersion = errorObject.AssemblyVersion, Created = errorObject.Created, ErrorNameSpace = errorObject.ErrorNameSpace, MethodName = errorObject.MethodName, NameSpace = errorObject.NameSpace, Group = errorObject.ErrorGroup.HasValue ? (byte?)errorObject.ErrorGroup.Value : null, Severity = errorObject.ErrorSeverity.HasValue ? (byte?)errorObject.ErrorSeverity.Value : null }; if (errorObject.ErrorData != null && errorObject.ErrorData.Count > 0) { foreach (var errorDataDetail in errorObject.ErrorData) { var databaseErrorData = new DataModels.Exception.ExceptionData { DataType = (byte)errorDataDetail.DataType, Name = errorDataDetail.Key, Data = errorDataDetail.Value }; databaseError.ExceptionData.Add(databaseErrorData); } } if (errorObject.ErrorExceptions != null) foreach (var exception in errorObject.ErrorExceptions) { var exceptionErrorDetail = new DataModels.Exception.ExceptionDetail(); exceptionErrorDetail.Depth = exception.Depth; exceptionErrorDetail.Message = exception.Message; exceptionErrorDetail.MethodName = exception.MethodName; exceptionErrorDetail.StackTrace = exception.StackTrace; databaseError.ExceptionDetails.Add(exceptionErrorDetail); } dc.ErrorExceptions.Add(databaseError); dc.SaveChanges(); } catch (Exception except) { AddException(except, except.GetType()); } }