2

For years I have had code similar to the following, and it has always worked fine.
But now we recently updated to Win 11, perhaps it is related or there is some other update or policy change that happened at the same time.

But essentially, I can't read the mail I create from Excel, and I can't use ReplyRecipients.
Is this related to an recent update, or can this code get back to working condition again?

I realize the two lines of .To can be one line, but that isn't the solution.
I'm asking if we can read from the .To field and this code kind of demonstrates it.
We are using the old Outlook app.
The code requires the Outlook 16.0 Object library as a reference.

The error we get is 287.

Code below is for Excel VBA.

Sub mail()
    Dim OutlookApp As Outlook.Application
    Dim OutlookMail As Outlook.MailItem

    Set OutlookApp = New Outlook.Application
    Set OutlookMail = OutlookApp.CreateItem(olMailItem)
    With OutlookMail
        .BodyFormat = olFormatHTML
        .Display
        Signature = .HTMLBody                       ' does not work
        .HTMLBody = "<b>Hello</b><br>" & Signature  ' works ( without signature) 
        .ReplyRecipients.Add "[email protected]"       ' does not work
        .To = "[email protected]"                      ' works
        .To = .To & "; [email protected]"              ' does not work
    End With
End Sub
28
  • 1
    Maybe this is helpful: stackoverflow.com/questions/46397966/… Commented Nov 11 at 8:23
  • 4
    Again, what does does not work mean. You are saying you cannot read the value of the fields. Do you run into any error at the marked lines or are you just saying that for example Signature is not populated? Maybe you do not have a signature in your email at all, I would not know. And where do you get the error 287? At which line? Commented Nov 11 at 8:42
  • 1
    I am on Win 11, Office 365. Subscription Your code works for rme. Commented Nov 11 at 9:30
  • 1
    If .Recipients.Add is also throwing 287, that it maybe becuase of the Outlook Object Model Guard being enforced by company policy. Commented Nov 11 at 9:52
  • 3
    Your code just work fine to me with outlook-365 and Windows-11 25H2. I am sure, it is due to your IT system and security policy. Commented Nov 11 at 10:13

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.