I want to send an email to a distribution group, and make sure the recipients will get the email as it was send especially to them. meaning : in the "To" field I want them to see only their email address and not the group's name in bold letters.
I am building a subject router dll for Exchange, and I need to split emails sent to groups, to individual email messages. I'm 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 read only...
Any other ideas ?
Here is some sample code as requested:
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;
}
}
//}
}
}