public virtual void SendEmailWithDefaultSender(EmailMessage emailMessage, bool ignoreErrors) { MailCredentials credentials = new MailCredentials { Host = (string)SysSettings.GetValue(UserConnection, "SmtpHost"), Port = int.Parse(SysSettings.GetValue(UserConnection, "SmtpPort").ToString()), UseSsl = (bool)SysSettings.GetValue(UserConnection, "SmtpEnableSsl"), UserName = (string)SysSettings.GetValue(UserConnection, "SmtpUserName"), UserPassword = (string)SysSettings.GetValue(UserConnection, "SmtpUserPassword") }; string[] to = emailMessage.To.ToArray(); EmailAddressCollection cc = GetEmailAddressCollection(emailMessage.Cc); EmailAddressCollection bcc = GetEmailAddressCollection(emailMessage.Bcc); var smtpClient = new SmtpClient(UserConnection); MailMessage mailBeeMessage = smtpClient.CreateMessage(emailMessage.Body, emailMessage.Subject, to, credentials.UserName, true, new Dictionary <Guid, Tuple <byte[], string> >(0)); mailBeeMessage.Cc = cc; mailBeeMessage.Bcc = bcc; mailBeeMessage.Priority = (MailPriority)emailMessage.Priority; try { smtpClient.SendMessage(mailBeeMessage, credentials); } catch (Exception e) { _log.Error(e); if (!ignoreErrors) { throw; } } }
/// <summary Get Collection> /// Get collection of emails. If no records to return, EmailCollection will be null. /// </summary> /// <returns></returns> public static EmailAddressCollection GetCollection(int employeeId) { EmailAddressCollection tempList = null; using (SqlConnection myConnection = new SqlConnection(AppConfiguration.ConnectionString)) { using (SqlCommand myCommand = new SqlCommand("usp_GetEmail", myConnection)) { myCommand.CommandType = CommandType.StoredProcedure; myCommand.Parameters.AddWithValue("@QueryId", SelectTypeEnum.GetCollectionById); myCommand.Parameters.AddWithValue("@EmployeeId", employeeId); myConnection.Open(); using (SqlDataReader myReader = myCommand.ExecuteReader()) { if (myReader.HasRows) { tempList = new EmailAddressCollection(); while (myReader.Read()) { tempList.Add(FillDataRecord(myReader)); } } myReader.Close(); } } } return tempList; }
private void Initialise() { this._blindedCarbonCopies = new EmailAddressCollection(); this._carbonCopies = new EmailAddressCollection(); this._contentTransferEncoding = EContentTransferEncoding.SevenBit; this._contentType = new Net.Common.ContentType(); this._extraHeaders = new ExtraHeadersDictionary(); this._isDefaultContentTransferEncoding = true; this._isDefaultContentType = true; this._keywords = new List <string>(); this._replyTo = new EmailAddressCollection(); this._resentBlindedCarbonCopies = new EmailAddressCollection(); this._resentCarbonCopies = new EmailAddressCollection(); this._resentTo = new EmailAddressCollection(); this._comments = string.Empty; this._contentDescription = string.Empty; this._contentId = string.Empty; this._inReplyTo = string.Empty; this._messageId = string.Empty; this._received = string.Empty; this._references = string.Empty; this._resentMessageId = string.Empty; this._subject = string.Empty; this._text = string.Empty; this._textEncoding = Encoding.UTF8; this._to = new EmailAddressCollection(); this._importance = MailImportance.Normal; }
private void SetRecipient(EmailAddressCollection emailAddressCollection, GXMailRecipientCollection gXMailRecipientCollection) { foreach (GXMailRecipient to in gXMailRecipientCollection) { emailAddressCollection.Add(new EmailAddress(to.Name, to.Address)); } }
/// <summary> /// Return all offices /// </summary> public List <Model.Office> GetOffices(string userEmail) { EmailAddressCollection roomLists = service.GetRoomLists(); // GetRoomLists - return offices list List <Model.Office> offices = new List <Model.Office>(); var user = GetUser(userEmail); foreach (EmailAddress ssAddress in roomLists) { //"Chernivtsi Office Meeting Rooms List" string name = ssAddress.Name.Replace("Meeting Rooms List", "").Trim(); bool isFavourite = true; if (user.FavouriteOffice == null || user.FavouriteOffice.Email != ssAddress.Address) { isFavourite = false; } offices.Add(new Model.Office() { Email = ssAddress.Address, Name = name, IsFavourite = isFavourite }); } return(offices.OrderBy(e => !e.IsFavourite).ThenBy(e => e.Name).ToList()); }
private static void GetRooms(ExchangeService service) { // Return all the room lists in the organization. EmailAddressCollection roomLists = service.GetRoomLists(); // Retrieve the room list that matches your criteria. // Replace "*****@*****.**" with the room list you are looking for. EmailAddress roomAddress = new EmailAddress("*****@*****.**"); foreach (EmailAddress address in roomLists) { if (address == roomAddress) { Console.WriteLine("Found {0} in room list", roomAddress); } else { Console.WriteLine("No matching room list found."); return; } } // Expand the selected collection to get a list of rooms. System.Collections.ObjectModel.Collection <EmailAddress> roomAddresses = service.GetRooms(roomAddress); // Display the individual rooms. foreach (EmailAddress address in roomAddresses) { Console.WriteLine("Email Address: {0}", address.Address); } }
/// <summary> /// 取消会议室指定时间段的会议 /// </summary> /// <param name="config"></param> /// <param name="roomName">会议室名称</param> /// <param name="startTime">会议开始时间</param> /// <param name="endDateTime">会议结束时间</param> /// <returns></returns> public static void CancelMeeting(ExchangeAdminConfig config, string roomName, DateTime startTime, DateTime endDateTime) { InitializeEws(config); //Service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "*****@*****.**"); EmailAddressCollection listOfRoomList = Service.GetRoomLists(); foreach (EmailAddress address in listOfRoomList) { var roomAddresses = Service.GetRooms(address); foreach (EmailAddress roomAddress in roomAddresses) { if (roomAddress.Name != roomName && roomAddress.Address != roomName) { continue; } CalendarView calendarView = new CalendarView(startTime, endDateTime); FolderId folderId = new FolderId(WellKnownFolderName.Calendar, roomAddress.Address); var roomAppts = Service.FindAppointments(folderId, calendarView); if (roomAppts.Items.Count > 0) { foreach (Appointment appt in roomAppts) { Appointment meeting = Appointment.Bind(Service, appt.Id, new PropertySet()); meeting.CancelMeeting(); } } } } }
internal static string GetValue(EmailAddressCollection emails, bool singleLine) { if (emails == null) { return(string.Empty); } StringBuilder sb = new StringBuilder(); sb.AppendLine(string.Format(System.Globalization.CultureInfo.CurrentCulture, "Length: {0}", emails.Count)); sb.AppendLine(); int i = 0; foreach (EmailAddress email in emails) { sb.AppendLine(string.Format(System.Globalization.CultureInfo.CurrentCulture, "EmailAddress [{0}]", i)); sb.AppendLine(EmailAddressTypeValue.GetValue(email, true)); sb.AppendLine(); sb.AppendLine(); i++; } return(sb.ToString()); }
public EmailAddressCollection ParseTo(string text) { if (text == null) { throw new ArgumentNullException("text"); } EmailAddressCollection addresss = new EmailAddressCollection(); Match match = regTo.Match(text); if (match.Success && (match.Groups.Count > 0)) { foreach (Match match2 in regAddressAll.Matches(match.Groups[0].Value)) { EmailAddress address = this.ParseEmail(match2.Groups[1].Value); if (address != null) { addresss.Add(address); } } return(addresss); } foreach (Match match3 in regAddressAll.Matches(text)) { EmailAddress address2 = this.ParseEmail(match3.Groups[1].Value); if (address2 != null) { addresss.Add(address2); } } return(addresss); }
/// <summary> /// 获取会议室列表 /// </summary> /// <returns>会议室列表</returns> public static EmailAddressCollection GetRoomList(ExchangeAdminConfig config) { InitializeEws(config); EmailAddressCollection roomList = Service.GetRoomLists(); return(roomList); }
: super() { this.assignCategories = new StringList(); this.forwardAsAttachmentToRecipients = new EmailAddressCollection(XmlElementNames.Address); this.forwardToRecipients = new EmailAddressCollection(XmlElementNames.Address); this.redirectToRecipients = new EmailAddressCollection(XmlElementNames.Address); this.sendSMSAlertToRecipients = new Collection <MobilePhone>(); }
public void Add_EmailAddressUnknownToEmptyCollection_DoesNotExtendTheCollection() { var exp = new EmailAddressCollection(); var act = new EmailAddressCollection(); act.Add(EmailAddress.Unknown); CollectionAssert.AreEqual(exp, act); }
public void Add_EmailAddressUnknownToEmptyCollection_DoesNotExtendTheCollection() { var exp = new EmailAddressCollection(); var act = new EmailAddressCollection(); act.Add(EmailAddress.Unknown); CollectionAssert.AreEqual(exp, act); }
public void ConstructorWithInitialIListAddsToList() { IList <EmailAddress> initial = new List <EmailAddress> { new EmailAddress(), new EmailAddress() }; var emailAddressCollection = new EmailAddressCollection(initial); Assert.Equal(2, emailAddressCollection.Count); }
/// <summary> /// 获取exchange 会议室记录 /// </summary> public static List <MeetRoomEntity> GetRoomList(ExchangeAdminConfig config, DateTime startTime, DateTime endDateTime) { ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2013_SP1); service.Credentials = new NetworkCredential(config.AdminAccount, config.AdminPwd); service.Url = new Uri($"http://{config.ServerIpOrDomain}/ews/exchange.asmx"); service.UseDefaultCredentials = false; List <MeetRoomEntity> result = new List <MeetRoomEntity>(); EmailAddressCollection listOfRoomList = service.GetRoomLists(); foreach (EmailAddress address in listOfRoomList) { var roomAddresses = service.GetRooms(address); foreach (EmailAddress roomAddress in roomAddresses) { MeetRoomEntity roomEntity = new MeetRoomEntity() { StartDate = startTime, EndDate = endDateTime, MeetEmail = roomAddress.Address, Name = roomAddress.Name }; CalendarView calendarView = new CalendarView(startTime, endDateTime); FolderId folderId = new FolderId(WellKnownFolderName.Calendar, roomAddress.Address); var roomAppts = service.FindAppointments(folderId, calendarView); List <MeetInfoEntity> meets = new List <MeetInfoEntity>(); if (roomAppts.Items.Count > 0) { foreach (Appointment appt in roomAppts) { meets.Add(new MeetInfoEntity { StartDate = appt.Start, EndDate = appt.End, Subject = appt.Subject }); } roomEntity.Meetings = meets; } result.Add(roomEntity); } } return(result); // listOfRoomList==0 执行下面语句 把会议室归类 // $members=Get-Mailbox -Filter {(RecipientTypeDetails -eq "RoomMailbox")} //New - DistributionGroup - Name "Poole-Rooms" - RoomList - Members $Members // 最好可能还需要设置权限 // Add-MailboxFolderPermission -Identity [email protected]:\Calendar -AccessRights Owner -User [email protected] }
public string GetValue(object ownerInstance, PropertyInfo propInfo) { string text = string.Empty; EmailAddressCollection emails = propInfo.GetValue(ownerInstance, null) as EmailAddressCollection; return(GetValue(emails, false)); }
public ConstituentInfo(DataSet tessResults) { DataTableCollection tables = tessResults.Tables; if (tables.Contains("Addresses") && tables["Addresses"].Rows.Count > 0) { Addresses = new AddressCollection(tables["Addresses"]); } if (tables.Contains("ConstituentAttribute") && tables["ConstituentAttribute"].Rows.Count > 0) { Attributes = new ConstituentAttributeCollection(tables["ConstituentAttribute"]); } if (tables.Contains("EmailAddresses") && tables["EmailAddresses"].Rows.Count > 0) { EmailAddresses = new EmailAddressCollection(tables["EmailAddresses"]); } if (tables.Contains("Associations") && tables["Associations"].Rows.Count > 0) { Associations = new AssociationCollection(tables["Associations"]); } if (tables.Contains("Constituency") && tables["Constituency"].Rows.Count > 0) { Constituencies = new ConstituencyCollection(tables["Constituency"]); } if (tables.Contains("ConstituentHeader") && tables["ConstituentHeader"].Rows.Count > 0) { Header = new ConstituentHeader(tables["ConstituentHeader"]); } if (tables.Contains("Contribution") && tables["Contribution"].Rows.Count > 0) { Contributions = new ContributionRecordCollection(tables["Contribution"]); } if (tables.Contains("Interests") && tables["Interests"].Rows.Count > 0) { Interests = new InterestCollection(tables["Interests"]); } if (tables.Contains("Memberships") && tables["Memberships"].Rows.Count > 0) { Memberships = new MembershipCollection(tables["Memberships"]); } if (tables.Contains("Phones") && tables["Phones"].Rows.Count > 0) { PhoneNumbers = new PhoneNumberCollection(tables["Phones"]); } if (tables.Contains("ProgramListings") && tables["ProgramListings"].Rows.Count > 0) { ProgramListings = new ProgramListingCollection(tables["ProgramListings"]); } if (tables.Contains("Rankings") && tables["Rankings"].Rows.Count > 0) { Rankings = new RankCollection(tables["Rankings"]); } }
/// <summary> /// Convert the SMS recipient list from MobilePhone collection type to EmailAddressCollection type. /// </summary> /// <param name="recipientCollection">Recipient list in a MobilePhone collection type.</param> /// <returns>An EmailAddressCollection object containing recipients with "MOBILE" address type. </returns> private static EmailAddressCollection ConvertSMSRecipientsFromMobilePhoneCollectionToEmailAddressCollection(Collection<MobilePhone> recipientCollection) { EmailAddressCollection emailCollection = new EmailAddressCollection(XmlElementNames.Address); foreach (MobilePhone recipient in recipientCollection) { EmailAddress emailAddress = new EmailAddress( recipient.Name, recipient.PhoneNumber, RuleActions.MobileType); emailCollection.Add(emailAddress); } return emailCollection; }
private void AddAdressesToCollection( EmailAddressCollection adresses, string firstAdress = null) { adresses.Add(firstAdress ?? this.RndRecipMail()); if (RndTrueFalse() && this.recipientsMax > 1) { adresses.Add(this.RndRecipMail()); } }
public void TryParse_StringEmpty_EmptyCollection() { EmailAddressCollection exp = new EmailAddressCollection(); EmailAddressCollection act; Assert.IsTrue(EmailAddressCollection.TryParse(string.Empty, out act)); CollectionAssert.AreEqual(exp, act); }
public void TryParse_SingleEmailAddress_CollectionWithOneItems() { var act = EmailAddressCollection.TryParse("*****@*****.**"); var exp = new EmailAddressCollection(){ EmailAddress.Parse("*****@*****.**") }; CollectionAssert.AreEqual(exp, act); }
public void TryParse_Null_EmptyCollection() { EmailAddressCollection exp = new EmailAddressCollection(); EmailAddressCollection act; Assert.IsTrue(EmailAddressCollection.TryParse(null, out act)); CollectionAssert.AreEqual(exp, act); }
public void TryParse_Invalid_EmptyCollection() { var act = EmailAddressCollection.TryParse("invalid"); var exp = new EmailAddressCollection(); CollectionAssert.AreEqual(exp, act); }
public void ToString_EmptyCollection_StringEmpty() { var collection = new EmailAddressCollection(); var exp = string.Empty; var act = collection.ToString(); Assert.AreEqual(exp, act); }
/// <summary> /// Tries to read element from XML. /// </summary> /// <param name="reader">The reader.</param> /// <returns>True if element was read.</returns> internal override bool TryReadElementFromXml(EwsServiceXmlReader reader) { switch (reader.LocalName) { case XmlElementNames.AssignCategories: this.assignCategories.LoadFromXml(reader, reader.LocalName); return true; case XmlElementNames.CopyToFolder: reader.ReadStartElement(XmlNamespace.NotSpecified, XmlElementNames.FolderId); this.copyToFolder = new FolderId(); this.copyToFolder.LoadFromXml(reader, XmlElementNames.FolderId); reader.ReadEndElement(XmlNamespace.NotSpecified, XmlElementNames.CopyToFolder); return true; case XmlElementNames.Delete: this.delete = reader.ReadElementValue<bool>(); return true; case XmlElementNames.ForwardAsAttachmentToRecipients: this.forwardAsAttachmentToRecipients.LoadFromXml(reader, reader.LocalName); return true; case XmlElementNames.ForwardToRecipients: this.forwardToRecipients.LoadFromXml(reader, reader.LocalName); return true; case XmlElementNames.MarkImportance: this.markImportance = reader.ReadElementValue<Importance>(); return true; case XmlElementNames.MarkAsRead: this.markAsRead = reader.ReadElementValue<bool>(); return true; case XmlElementNames.MoveToFolder: reader.ReadStartElement(XmlNamespace.NotSpecified, XmlElementNames.FolderId); this.moveToFolder = new FolderId(); this.moveToFolder.LoadFromXml(reader, XmlElementNames.FolderId); reader.ReadEndElement(XmlNamespace.NotSpecified, XmlElementNames.MoveToFolder); return true; case XmlElementNames.PermanentDelete: this.permanentDelete = reader.ReadElementValue<bool>(); return true; case XmlElementNames.RedirectToRecipients: this.redirectToRecipients.LoadFromXml(reader, reader.LocalName); return true; case XmlElementNames.SendSMSAlertToRecipients: EmailAddressCollection smsRecipientCollection = new EmailAddressCollection(XmlElementNames.Address); smsRecipientCollection.LoadFromXml(reader, reader.LocalName); this.sendSMSAlertToRecipients = ConvertSMSRecipientsFromEmailAddressCollectionToMobilePhoneCollection(smsRecipientCollection); return true; case XmlElementNames.ServerReplyWithMessage: this.serverReplyWithMessage = new ItemId(); this.serverReplyWithMessage.LoadFromXml(reader, reader.LocalName); return true; case XmlElementNames.StopProcessingRules: this.stopProcessingRules = reader.ReadElementValue<bool>(); return true; default: return false; } }
/// <summary> /// Initializes a new instance of the <see cref="RulePredicates"/> class. /// </summary> internal RulePredicates() : base() { this.categories = new StringList(); this.containsBodyStrings = new StringList(); this.containsHeaderStrings = new StringList(); this.containsRecipientStrings = new StringList(); this.containsSenderStrings = new StringList(); this.containsSubjectOrBodyStrings = new StringList(); this.containsSubjectStrings = new StringList(); this.fromAddresses = new EmailAddressCollection(XmlElementNames.Address); this.fromConnectedAccounts = new StringList(); this.itemClasses = new StringList(); this.messageClassifications = new StringList(); this.sentToAddresses = new EmailAddressCollection(XmlElementNames.Address); this.withinDateRange = new RulePredicateDateRange(); this.withinSizeRange = new RulePredicateSizeRange(); }
/// <summary> /// Initializes a new instance of the <see cref="RulePredicates"/> class. /// </summary> internal RuleActions() : base() { this.assignCategories = new StringList(); this.forwardAsAttachmentToRecipients = new EmailAddressCollection(XmlElementNames.Address); this.forwardToRecipients = new EmailAddressCollection(XmlElementNames.Address); this.redirectToRecipients = new EmailAddressCollection(XmlElementNames.Address); this.sendSMSAlertToRecipients = new Collection<MobilePhone>(); }
private static EmailAddressCollection GetAddressesFromTable(DataTable addressTable, string className) { EmailAddressCollection addresses = new EmailAddressCollection(); DataView view = GetAddressViewByClassName(addressTable, className); foreach (DataRowView drv in view) { EmailAddress address = new EmailAddress(); ORMapping.DataRowToObject(drv.Row, address); addresses.Add(address); } return addresses; }
/// <summary> /// Convert the SMS recipient list from EmailAddressCollection type to MobilePhone collection type. /// </summary> /// <param name="emailCollection">Recipient list in EmailAddressCollection type.</param> /// <returns>A MobilePhone collection object containing all SMS recipient in MobilePhone type. </returns> private static Collection<MobilePhone> ConvertSMSRecipientsFromEmailAddressCollectionToMobilePhoneCollection(EmailAddressCollection emailCollection) { Collection<MobilePhone> mobilePhoneCollection = new Collection<MobilePhone>(); foreach (EmailAddress emailAddress in emailCollection) { mobilePhoneCollection.Add(new MobilePhone(emailAddress.Name, emailAddress.Address)); } return mobilePhoneCollection; }
private static void WriteInsertAddressCollection(TextWriter writer, EmailAddressCollection addresses, string messageID, string className) { for (int i = 0; i < addresses.Count; i++) WriteInsertAddressSql(writer, addresses[i], messageID, className, i); }
public void ToString_2Items_infoAtQowaivDotOrgCommaTestAtQowaivDotOrg() { var collection = new EmailAddressCollection(EmailAddress.Parse("*****@*****.**"), EmailAddress.Parse("*****@*****.**")); var exp = "[email protected],[email protected]"; var act = collection.ToString(); Assert.AreEqual(exp, act); }
private static EmailAddressCollection GetExistOrNewAddressColleciton(EmailAddressCollection originalAddresses) { EmailAddressCollection result = originalAddresses; if (result == null) result = new EmailAddressCollection(); return result; }