none
OLE IDispatch exception code 4096 from Microsoft Outlook: Outlook does not recognize one or more names RRS feed

  • Question

  • Hi All,

    Following is my code where I add my recipients. Also I DO NOT call any Recipients.ResolveAll methods in my code. But when I try to send emails via Ms Outlook, it generates following error.

    OLE IDispatch exception code 4096 from Microsoft Outlook: Outlook does not recognize one or more names

    Env: Ms Outlook 2010 32bit, Ms Exchange Server 2010, Windows Vista.

    loOutlookSession = CREATEOBJECT("Outlook.Application")
    loOutBox = loOutlooksession.GetNameSpace("MAPI").GetDefaultFolder(nOutBox)
    loOutlookMailItem = loOutBox.Items.Add(nMailItem)
    loOutlookRecipient = loOutlookMailItem.Recipients.Add(“ecasper@dummy.biz”)
    loOutlookRecipient.Type = 1 && To
    loOutlookRecipient = NULL
     
    loOutlookRecipient = loOutlookMailItem.Recipients.Add(“Idiot@dummy.com”)
    loOutlookRecipient.Type = 2 && CC
    loOutlookRecipient = NULL

    Please help!

    Cheers!


    • Edited by eCasper Wednesday, July 11, 2012 7:34 AM
    Wednesday, July 11, 2012 7:31 AM

All replies

  • 2 questions. Why are you nulling the recipient objects after you create them? Why aren't you using Resolve() on each recipient or ResolveAll() on the entire Recipients collection?

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "eCasper" <=?utf-8?B?ZUNhc3Blcg==?=> wrote in message news:34e477fd-3173-44e2-8247-f2659d384f7d...

    Hi All,

    Following is my code where I add my recipients. Also I DO NOT call any Recipients.ResolveAll methods in my code. But when I try to send emails via Ms Outlook, it generates following error.

    OLE IDispatch exception code 4096 from Microsoft Outlook: Outlook does not recognize one or more names

    Env: Ms Outlook 2010 32bit, Ms Exchange Server 2010, Windows Vista.

    loOutlookSession = CREATEOBJECT("Outlook.Application")
    loOutBox = loOutlooksession.GetNameSpace("MAPI").GetDefaultFolder(nOutBox)
    loOutlookMailItem = loOutBox.Items.Add(nMailItem)
    loOutlookRecipient = loOutlookMailItem.Recipients.Add(“ecasper@dummy.biz”)
    loOutlookRecipient.Type = 1 && To
    loOutlookRecipient = NULL
     
    loOutlookRecipient = loOutlookMailItem.Recipients.Add(“Idiot@dummy.com”)
    loOutlookRecipient.Type = 2 && CC
    loOutlookRecipient = NULL

    Please help!

    Cheers!



    Ken Slovak MVP - Outlook
    Wednesday, July 11, 2012 3:14 PM
    Moderator
  • Hi Ken, Thanks!

     1. That is because assigning recipients has been done in a loop. I did not not mention the loop here to keep things simple.

     2. I don't need to as I already know the recipient's email address.

    This problem is specif for few recipients that do not exist in user's Ms outlook address book but those recipients exist in Exchange server where particular user doesn't have access to. I'm sorry as I'm not sure whether my client had explained me the scenorio well.


    Cheers!

    Thursday, July 12, 2012 5:44 AM
  • I really have no idea why you are so resistant to using a Resolve() or ResolveAll() call, why won't you try it and see if it helps?
     
    Outlook never rejects a recipient just because it's not in one of the address books or GAL. If that was the case you could only send to people you already have in your address books. If a recipient address is formatted correctly as an SMTP or other supported format recipient such as X400 or X500, the address should be accepted.
     
    The address might be rejected by the receiving email server for various reasons, but that won't keep Outlook from sending to that person. It would just produce a non-delivery report.
     
    Can you send to the same address manually, not using code?

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "eCasper" <=?utf-8?B?ZUNhc3Blcg==?=> wrote in message news:b47a0622-3f3b-4a4b-bd10-29a7ab419dd9...

    Hi Ken, Thanks!

     1. That is because assigning recipients has been done in a loop. I did not not mention the loop here to keep things simple.

     2. I don't need to as I already know the recipient's email address.

    This problem is specif for few recipients that do not exist in user's Ms outlook address book but those recipients exist in Exchange server where particular user doesn't have access to. I'm sorry as I'm not sure whether my client had explained me the scenorio well.


    Cheers!


    Ken Slovak MVP - Outlook
    Thursday, July 12, 2012 3:00 PM
    Moderator
  • Hi Ken,

    I got the user to try sending mails manually to the same set of receipients that had failed and email has been set without any issues.

    Then I tried the same code with Redemption SaftMailItem and it produced the following error:

    OLE IDispatch exception code 0 from Redemption.SafeMailItem: Could not resolve the message recipients...

    Then I changed the code as below. But still it generates the above error.

    i.e.

    OLE IDispatch exception code 0 from Redemption.SafeMailItem: Could not resolve the message recipients...

    loOutlookSession = CREATEOBJECT("Outlook.Application") loOutBox = loOutlooksession.GetNameSpace("MAPI").GetDefaultFolder(nOutBox) loOutlookMailItem = CREATEOBJECT("Redemption.SafeMailItem") loOutlookMailItem.Item = loOutBox.Items.Add(nMailItem) loOutlookMailItem.Recipients.AddEx(“ecasper@dummy.biz”, “ecasper@dummy.biz”, "SMTP", 1) && To loOutlookMailItem.Recipients.AddEx(“Idiot@dummy.com”, “Idiot@dummy.com”, "SMTP", 2) && Cc ** Assign other necessary properties here...

    ** If the Redemption is used to compose the mail, when the mail is sent it is copied ** into the Drafts folder of MSO and once gone it moves to the Sent Items folder. ** Hence Outbox is not used and if the MS Outlook is not online the mail remains in the Drafts folder until MS Outlook goes online. ** Therefore the user may not be aware of the mails pending to be sent out from MSO ** The following focefully moves the mail into Outbox of MSO and sends it from there. loOutBoxMailItem = loOutlookMailItem.Move(oOutBox) IF VARTYPE(loOutBoxMailItem) = "O" ** Create Safe mail items again and assign the moved mail item ** When the mail is moved the EnrtyID(GUID) of the mail changes ** At the beginning itself before the SafeMail item is used, if we move the item into Outbook ** the mail item will be visible in MS Outlook and if the composing of the mail fails, ** the mail item remains in MS Outlook and have to be Deleted. ** Therefore the following is done instead. ** If the object cannot be created it will be handled by the validation below RELEASE loMailItem loOutlookMailItem = CREATEOBJECT("Redemption.SafeMailItem") loOutlookMailItem.Item = loOutBoxMailItem ENDIF ** Once the mail is moved to Outbox to send, Replyrecipints are lost from the mail item ** Therefore it assigns Replyrecipients before it sends loOutlookMailItem.ReplyRecipients.Add("from@dummy.com") loOutlookMailItem.SEND()



    Cheers!

    Wednesday, July 25, 2012 4:57 AM
  • Which recipient causes the error? Can you send to just one of those 2?
     
    I still don't understand why you are so resistant to using the Resolve() method on each Recipient object. Why won't you try it?

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "eCasper" <=?utf-8?B?ZUNhc3Blcg==?=> wrote in message news:5c53e781-36d3-47af-af44-463b0e9f8cd5...

    Hi Ken,

    I got the user to try sending mails manually to the same set of receipients that had failed and email has been set without any issues.

    Then I tried the same code with Redemption SaftMailItem and it produced the following error:

    OLE IDispatch exception code 0 from Redemption.SafeMailItem: Could not resolve the message recipients...

    Then I changed the code as below. But still it generates the above error.

    i.e.

    OLE IDispatch exception code 0 from Redemption.SafeMailItem: Could not resolve the message recipients...

    loOutlookSession = CREATEOBJECT("Outlook.Application") loOutBox = loOutlooksession.GetNameSpace("MAPI").GetDefaultFolder(nOutBox) loOutlookMailItem = CREATEOBJECT("Redemption.SafeMailItem") loOutlookMailItem.Item = loOutBox.Items.Add(nMailItem) loOutlookMailItem.Recipients.AddEx(“ecasper@dummy.biz”, “ecasper@dummy.biz”, "SMTP", 1) && To loOutlookMailItem.Recipients.AddEx(“Idiot@dummy.com”, “Idiot@dummy.com”, "SMTP", 2) && Cc ** Assign other necessary properties here...

    ** If the Redemption is used to compose the mail, when the mail is sent it is copied ** into the Drafts folder of MSO and once gone it moves to the Sent Items folder. ** Hence Outbox is not used and if the MS Outlook is not online the mail remains in the Drafts folder until MS Outlook goes online. ** Therefore the user may not be aware of the mails pending to be sent out from MSO ** The following focefully moves the mail into Outbox of MSO and sends it from there. loOutBoxMailItem = loOutlookMailItem.Move(oOutBox) IF VARTYPE(loOutBoxMailItem) = "O" ** Create Safe mail items again and assign the moved mail item ** When the mail is moved the EnrtyID(GUID) of the mail changes ** At the beginning itself before the SafeMail item is used, if we move the item into Outbook ** the mail item will be visible in MS Outlook and if the composing of the mail fails, ** the mail item remains in MS Outlook and have to be Deleted. ** Therefore the following is done instead. ** If the object cannot be created it will be handled by the validation below RELEASE loMailItem loOutlookMailItem = CREATEOBJECT("Redemption.SafeMailItem") loOutlookMailItem.Item = loOutBoxMailItem ENDIF ** Once the mail is moved to Outbox to send, Replyrecipints are lost from the mail item ** Therefore it assigns Replyrecipients before it sends loOutlookMailItem.ReplyRecipients.Add("from@dummy.com") loOutlookMailItem.SEND()



    Cheers!


    Ken Slovak MVP - Outlook
    Wednesday, July 25, 2012 1:27 PM
    Moderator
  • Hi Ken, Both Redemption & OOM produces the same type of errors. Same code works for thousands of my other clients. So I was wondering what makes you think that Resolve() will help here. Even I guess Resolve() is not a mandatory function that everyone must use because Resolve() does not occur unless we hit CTRL + K when sending mails manually via MS Outlook (correct me if I’m wrong).

    I badly need to find out the cause of the issue here rather than a solution first.

    Please help!


    Cheers!


    • Edited by eCasper Thursday, July 26, 2012 5:01 AM
    Thursday, July 26, 2012 5:00 AM
  • I'd like you to try using Resolve() and see what happens. It might provide an error message that's more useful than what you're getting now.
     
    Also, when using Exchange it can be very helpful to call Resolve() to make sure the items will go out correctly.
     
    Is the problem address hidden from the GAL, or in a different GAL than the user has access to, or is it an Exchange recipient with no corresponding SMTP address?

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "eCasper" <=?utf-8?B?ZUNhc3Blcg==?=> wrote in message news:36e77286-8c6e-4b8b-9b08-ff09a95a2492...

    Hi Ken, Both Redemption & OOM produces the same type of errors. Same code works for thousands of my other clients. So I was wondering what makes you think that Resolve() will help here. Even I guess Resolve() is not a mandatory function that everyone must use because Resolve() does not occur unless we hit CTRL + K when sending mails manually via MS Outlook (correct me if I’m wrong).

    I badly need to find out the cause of the issue here rather than a solution first.

    Please help!


    Cheers!



    Ken Slovak MVP - Outlook
    Thursday, July 26, 2012 1:15 PM
    Moderator
  • Hi Ken, I did not try with Resolve() as yet because I tried with AddEx + Redemption and made no progress. So now I’m afraid that the client might feel that we treat them as Guinea pigs. :) I'm really sorry about that.

    Anyway they have Contacts + Offline Global Address book.

    IMPORTANT: This problem only emerges if recipients belong to Contact are selected. Also user doesn’t have access to Contacts via the local PC. User only has access to recipients with offline GAL.

    All the recipients in both Offline GAL & Contacts are SMTP and also I guess above error triggers when the .Send() method fires.

    I guess now we have enough information to resolve this issue. don't we?

    It seems when you use MS Outlook in Cached Exchange Mode, Outlook verifies and resolves the names of e-mail recipients with the Offline Address Book automatically. Can that be the cause of the issue?

    http://support.microsoft.com/kb/831124


    Cheers!



    • Edited by eCasper Monday, August 6, 2012 10:02 AM
    Monday, August 6, 2012 5:50 AM
  • What was the problem wiht AddEx? I thought the names are resolved just fine when you use that method?

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

    Monday, August 6, 2012 2:48 PM
  • I don't have much more information than before, but why are the user's contacts not available to them? I don't understand that at all. Contacts are stored in the user's own mailbox, so why wouldn't they be available.
     
    I'd also repeat Dmitry's question about RDO's AddEx().

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "eCasper" <=?utf-8?B?ZUNhc3Blcg==?=> wrote in message news:68b115dd-4d84-459d-b9bf-a89614a6beae...

    Hi Ken, I did not try with Resolve() as yet because I tried with AddEx + Redemption and made no progress. So now I’m afraid that the client might feel that we treat them as Guinea pigs. :) I'm really sorry about that.

    Anyway they have Contacts + Offline Global Address book.

    IMPORTANT: This problem only emerges if recipients belong to Contact are selected. Also user doesn’t have access to Contacts via the local PC. User only has access to recipients with offline GAL.

    All the recipients in both Offline GAL & Contacts are SMTP and also I guess above error triggers when the .Send() method fires.

    I guess now we have enough information to resolve this issue. don't we?

    It seems when you use MS Outlook in Cached Exchange Mode, Outlook verifies and resolves the names of e-mail recipients with the Offline Address Book automatically. Can that be the cause of the issue?

    http://support.microsoft.com/kb/831124


    Cheers!




    Ken Slovak MVP - Outlook
    Monday, August 6, 2012 3:08 PM
    Moderator