开发者

Using Redemption to send as another user

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 = "test@our-domain.co.uk";
    reply.Send();
    session.Logoff();
}

the mail sends fine but is sent from my address and not from optingout@our-domain.co.uk

if I use:

private void replyToMail(OutlookItem item)
{
    RDOSessionClass session = new RDOSessionClass();
    session.LogonExchangeM开发者_开发技巧ailbox("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 = "test@our-domain.co.uk";
    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...


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜