none
Outlook Interop and Send On Behalf Of - Client vs Code RRS feed

  • Question

  • Having trouble with something I thought would be straightforward.

    What I want to do:

    Collect email messages in an Exchange mailbox, use Outlook Interop to access that mail box and forward selected message to people based on the contents of the message.

    What I have:

    - I have a mailbox on an Exchange server, address-Example: testbox<at>domain.com

    - certain users have been granted perms to Send As testbox<at>domain.com, the account associated with that mailbox

    - Outlook is installed. I can connect to the mailbox and see the messages. From the Outlook client I can open them, modify them, and send them to users as needed. When they arrive at their new destination the From line indicates they came from testbox<at>domain.com.

    - I have a small C# program using Outlook Interop (on the same machine) that connects to the mailbox, and reads the messages just fine.

    As soon as I try to send the message using the code one of two things happens:

    - I get a bounce message in the inbox from Exchange server saying I cannot send on behalf of this user

    - If I try modifying the SendUsingAccount value prior to the send() it throws a similar perms error at runtime

    I suspect it has to do with the context of my logon credentials but I am at a loss as to what the exact problem is since I can open the Outlook client and access the mailbox just fine (including sending mail from that account). My code uses the same Outlook profile to establish the connection to the mailbox so I assume the credentials are the same.

    Environmentally the only difference between the two scenarios is that in the first I use Outlook to do the task and in the second I use the C# app other than that it is the same mailbox, same server, same client machine, same  profile, same user account logged on. 

    Any suggestions would be appreciated.

    Thanks,

    DK



    • Edited by DMK_WA Wednesday, August 13, 2014 8:38 PM
    Wednesday, August 13, 2014 7:48 PM

Answers

  • Do you get the Outlook security prompt dialog?

    If so, there are three main ways to avoid such dialog:

    1. Use a low-level code (Extended MAPI). Or any third party wrappers that are based on such API which doesn't generate security prompts.<br><br>

    2. Group policy settings allows to disable such warnings.

    3. You can use commercial components for supressing Outlook security prompts.

    You can read more about these options in the article at http://www.outlookcode.com/article.aspx?ID=52

    Thursday, August 14, 2014 3:19 PM

All replies

  • Hello,

    You need to delegate access to the mailbox to use the "sent on behalf" feature. You can read more about this in the following articles:

    Allow someone else to manage your mail and calendar at http://office.microsoft.com/en-us/outlook-help/allow-someone-else-to-manage-your-mail-and-calendar-HA010075081

    Exchange: How to delegate access (email and calendar) to another user at http://helpdesk.princeton.edu/kb/display.plx?ID=9829


    What code do you use for getting the job done? What line of code fires an exception?
    Thursday, August 14, 2014 4:55 AM
  • Thanks for the reply Eugene. This mailbox is managed by our organization's Exchange administrators. I have gone through their process to get perms for my account on this mailbox. I can logon to the client machine with my credentials, open the Outlook client with my credentials and successfully send mail from the mailbox so it appears those perms are working.

    I think I have determined that the real issue I am running into is an anti-virus feature of Outlook. I made progress last night and managed to (using code) read mail, parse messages, build new messages based on content in the original messages, and successfully send the new message.

    The catch was that in order to send the new message I had to click a series of OKs in dialogs that were asking me to confirm that a) I knew a program was accessing the mailbox to get information, and b) I knew that another program was sending email in behalf of that mailbox. This is the anti-virus feature I mentioned earlier.

    There is s setting to turn this off under Options however in my organization this is controlled via Group Policy and I am not allowed to turn it off. There are a few suggested workarounds for this (example: extra threads that watch for the dialog and click OK for you) but they are ugly.

    At this point I think I am going to explore a different solution.

    Thursday, August 14, 2014 3:07 PM
  • Do you get the Outlook security prompt dialog?

    If so, there are three main ways to avoid such dialog:

    1. Use a low-level code (Extended MAPI). Or any third party wrappers that are based on such API which doesn't generate security prompts.<br><br>

    2. Group policy settings allows to disable such warnings.

    3. You can use commercial components for supressing Outlook security prompts.

    You can read more about these options in the article at http://www.outlookcode.com/article.aspx?ID=52

    Thursday, August 14, 2014 3:19 PM