1
votes

When I view outlook I see my mailbox but also additional "business function" mailboxes. One of these is "optingout"

I've written a console app that loops through several of these function mailboxes (by enumerating the folders in my session) and grabs all of the mails so I can then loop through them and take actions depending on the mailbox, subject and body.

In one case I need to reply to an email to say that they have asked to unsubscribe but I can't find the email they've used (or supplied in the body) in our database and can they respond with the correct mail... this tends to be where people have mail forwarding and have forgotten (and we get a ridiculous amount of these!)

In the below code OutlookItem is a custom class not a redemption or outlook class

When I used:

private void replyToMail(OutlookItem item)
{
    RDOSession session = new RDOSession();
    session.Logon(null, null, null, true, null, null);
    RDOMail thisItem = session.GetMessageFromID(item.EntryID, item.StoreID, null);
    RDOMail reply = thisItem.Reply();
    reply.Subject = "Automated Response - Could not complete unsubscribe";
    reply.Body = "This is an automated response ...";
    reply.BCC = "[email protected]";
    reply.Send();
    session.Logoff();
}

the mail sends fine but is sent from my address and not from [email protected]

if I use:

private void replyToMail(OutlookItem item)
{
    RDOSessionClass session = new RDOSessionClass();
    session.LogonExchangeMailbox("optingout", "big.ol.mailserver");
    RDOMail thisItem = session.GetMessageFromID(item.EntryID, item.StoreID, null);
    RDOMail reply = thisItem.Reply();
    reply.Subject = "Automated Response - Could not complete unsubscribe";
    reply.Body = "This is an automated response ...";
    reply.BCC = "[email protected]";
    reply.Send();
    session.Logoff();
}

It throws an exception saying that the mail profile isn't configured

So how do I use redemption to reply to a message and control the sending address?

Many thanks in advance...

1

1 Answers

1
votes

The RDOMail-properties corresponding to the sender of a message are called SentOnBehalfOf*. If you can, set it by EntryID (i.e. SentOnBehalfOfEntryID) or by assigning the corresponding RDOAddressEntry object directly to the SentOnBehalfOf-property. Setting only the SentOnBehalfOfName-property runs the risk of name ambiguity.

Setting this requires that the account you use to log on to the Exchange store has "Send As" permissions for the adressbook entry that the message should be sent on behalf of.