Exchange - Distribution Group Separation

I want to send an email to the distribution group and make sure that the recipients will receive the email because it was specially sent to them. meaning: in the To field, I want them to see only their email address, and not the group name in bold.

I am creating a dll for an object router for Exchange, and I need to separate the emails sent to groups into separate emails. I am working on Exchange 2010. any ideas?

I want to do something like this:

messageEventArgs.MailItem.Message.To = messageEventArgs.MailItem.Recipients 

but unfortunately messageEventArgs.MailItem.Message.To is only read ...

Any other ideas?

Here is a sample code:

  void ownRoutingAgent_OnResolvedMessage(ResolvedMessageEventSource source, QueuedMessageEventArgs messageEventArgs) { bool forwardToSeg = false; if (true) EventViewerLogger.WriteInfo("FromAddress: " + messageEventArgs.MailItem.FromAddress.ToString()); if (true) EventViewerLogger.WriteInfo("SecureSenders: " + m_SecureSenderAddress); distGroupList = generateDistGroupList(); // Change origional Sender EMail Address to a random sender from the list of SEG users foreach (string senderAddr in m_SecureSenderAddress.Split(',')) { //Check if sender equals to a secure sender if (senderAddr.ToUpper() == (messageEventArgs.MailItem.FromAddress.ToString().ToUpper())) { Random rnd = new Random(); int numOfUser = rnd.Next(0, senderAddresses.Length); messageEventArgs.MailItem.FromAddress = new RoutingAddress(senderAddresses[numOfUser]); forwardToSeg = true; //Check if recepient is a distrebution group // run over all recipients list //foreach (EnvelopeRecipient recp in messageEventArgs.MailItem.Recipients) //{ // run over excluded members list foreach (MyClass disGrp in distGroupList) { // Checks if Recipients contain an e-mail group), // if yes, does not route to seg. if (messageEventArgs.MailItem.Message.To.ToString().ToUpper() == disGrp.emailAdress.ToUpper()) { messageEventArgs.MailItem.Message.To.Add******* = messageEventArgs.MailItem.Recipients //create a method that extracts group members and saves them in an array //delete group address from mail-recipients //messageEventArgs.MailItem.Recipients; return; } } //} } } 
0
c # email dll exchange-server
source share
1 answer

You can get a list of email messages from the group, and then send mail. The following snippet will receive individual mail identifiers.

  string groupName = "somegroup"; string domainName = "somedomain"; using(PrincipalContext ctx = new PrincipalContext(ContextType.Domain, domainName)) { using(GroupPrincipal grp = GroupPrincipal.FindByIdentity(ctx, IdentityType.Name, groupName)) { var sams = from x in grp.GetMembers(true) select new {x.SamAccountName, }; var users = from sam in a.Distinct() let usr = UserPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, sam) select new { usr.SamAccountName, usr.DisplayName, usr.EmailAddress}; //users is now populated with the e-mail IDs } } 

In addition, you can still use one email and save email addresses in the BCC field. Do not know what it is.

+1
source share

All Articles