-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
My first Add-In #5160
Comments
@exextoc, I've been doing some research on this and someone told me the following: Also note that you cannot concatenate two well-formed HTML documents and expect a valid HTML document as a result; the two must be merged.. Which makes a lot of sense because I'm essentially working with two HTML objects: the email template, which is created inside command.TS, and the signature, which is another HTML object. |
Have you looked at the string that is being used to set the body to see if the result is good HTML? Looking at the code I see that you are setting the body with new content. If I'm not mistaken that will overwrite the existing content including any signature that get's added . . . but I'm not certain on that. There may still be an issue with the signature getting inserted . . . I'm just not sure how that looks when you are replacing the body. I also noticed that you are using a timer instead of a call back in displayNewMessageFrom . . . that might give you problematic results as it creates a race condition between the displayNewMessageForm and timer. |
Hi, thank you so much for getting back to me. You’re absolutely right in your assessment. When the email loads, it adds the signature, but when the template is applied, the signature gets removed. This happens because I’m handling two separate HTML files. To address this, I merged both HTML files, which works perfectly in OWA. However, in the desktop version of Outlook, I’m encountering this issue: Uncaught TypeError: Office.context.mailbox.item.body.setAsync is not a function. This error occurs because the Any idea why this might be happening? I’ve attached the function in case you’d like to take a look and provide some guidance. ` Office.onReady(function (info) { /**
/**
/**
// Step 1: Select the template // Step 2: Retrieve the user's signature
}); Thanks in advance! |
When clicking the button you are making, your context is the current item displayed in read mode. So when you call "Office.context.mailbox.item" that is what you are getting in read mode, and you can't "setAsync" read mode content. Also, when you are calling "Office.context.mailbox.item.body.getAsync" you are getting the whole body of the current displayed email and not just the "signature" . . . so when you set the new email body you are including all the merged content which includes the entire content you retrieved from the existing email. |
Thank you very much for your explanation - that's exactly what's happening. Could you help me modify the function to correct what you indicated? I appreciated it so much. |
As far a generating a new email it looks like you're doing the right thing. It's pretty un-reliable to try and get the signature from the body of the current email. You have to let Outlook insert the signature on new emails like it would for any other new email. Just call displayNewMessageForm with the template content (not the body of the current email merged into it) and let Outlook do it's job. |
I hope you had a great holiday season with your family! Thanks for all your help - it's really appreciated. I've applied the changes you suggested, and if I understand correctly, this would be the result: `/* global Office */ /**
/**
/**
// Define the template content // Open a new email draft with the template content // Event completion Thank you again. |
I forgot to tell you that applying your suggestion, the process added the template properly but missed the signature block. Even having the signature set for new emails it's not pop up. Thank you, |
Looks like when you specify the htmlBody that is used completely, and the signature is not added. I have logged and internal issue to consider this behavior. I'm not sure what your total end goal is, but the OnNewMessageCompose event (which doesn't have the context of the current read item) can be used to insert a signature (see: https://learn.microsoft.com/en-us/samples/officedev/pnp-officeaddins/outlook-add-in-set-signature/), but you have to have the signature content to insert. Currently we don't have a way to get the existing signature settings and depend on the native or add-in signature insertion to get triggered. |
Looks like this is actually a design that has been that way for a while. If you want displayNewMessageForm to insert the signature after the content you specify in the htmlBody argument you'll have to make a feature request on Dev community: |
Hello everyone,
I’m working on developing my first Add-In for Outlook 365/Windows 10. In theory, it’s quite simple—it’s a drop-down menu with two options. Each option opens a new email and loads a different template, depending on the selection.
So far, the menu is functioning smoothly. Selecting option A displays the corresponding template, and the same goes for option B.
However, I’m facing a problem: I can’t get the user’s signature to load automatically as expected, even though the signature is properly configured and set as the default for new emails.
Attached you will find my manifest.xml and commands.ts
manifest.xml
commands.ts
Thank you so much for your support!
The text was updated successfully, but these errors were encountered: