none
OL14_MailItem SetSendUsingAccount not working RRS feed

  • Question

  • Hi,

    Before sending a e-mail by using an OL14_MailItem object I want to change the account which is used for sending the e-mail. I am using the following code for setting the account:

    pMailItem = new OL14_MailItem( pOLApp->CreateItem( 0 ) );

    ..... OL14_NameSpace nspace = pOLApp->GetNamespace("MAPI"); OL14_Accounts accounts = nspace.GetAccounts(); OL14_Account account; int i; for( i = 1; i <= accounts.GetCount(); i++) { VARIANT var; var.vt = VT_INT; var.intVal = i; account = accounts.Item(var); if( i == 2 ) { pMailItem->SetSendUsingAccoun(account ); } } pMailItem->Send();

    In my code I want to use my 2nd account to send the e-mail. But always the 1st account is used to send the e-mail. ( the code is written with Visual C++ 6.0).

    Does anybody know what the problem could be?

    regards,

    rgwerder




    • Edited by rgwerder Thursday, May 31, 2012 12:08 PM
    Thursday, May 31, 2012 12:06 PM

All replies

  • are you sure that 'if' with setting account is actually hit? And that second account is actually that one which you want?
    Thursday, May 31, 2012 1:01 PM
  • Note that Accounts.Item() can also take a string (account name), not just an integer index.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Thursday, May 31, 2012 4:42 PM
  • Hello Damian,

    The code above ist only test code and I am sure that I want to use the 2nd account for sending the e-mail, because the 1st one is the default one.
    I verified the account by using the 'account.GetSmtpAddress()' function, which returned me the correct e-mail address of the account.

    regards,
    rgwerder

    Friday, June 1, 2012 6:41 AM
  • Hello Dmitry,

    I have verified the returned account by using the 'account.GetSmtpAddress()' function which returned the expected results.

    regards,
    rgwerder

    Friday, June 1, 2012 6:43 AM
  • Do you see the right account stamp if you look at the message in the Sent Items folder with MFCMAPi or OutlookSpy (click IMessage)?

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.3 is now available!

    Friday, June 1, 2012 6:43 AM
  • Hi,

    There's a missing "T" in SetSendUsingAccount. Is that just in the code in this post or in your actual code?


    Bill Jacob - Microsoft Customer Service & Support - Developer Messaging

    Tuesday, June 5, 2012 2:12 PM
    Moderator