Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Sep 17, 2024 12:23 AM
Hello everyone,
I need a little help about how to preview an email before send it.
I explain myself, I need people who uses my interface to be able to preview their email before send it.
What I have now is when an entry is create by an automation I have a script who send it (Outlook) but don't allow to preview the mail.
I came up with an idea is to create a formula with "mailto" who allows to have an interaction with outlook with that I create a bouton and when people click on the bouton is create a preview of their mail directly on outlook with the information they put in a formulaire when the creation of an entry.
But I have two problems :
- "Mailto to" not allow html so I create a macro in Outlook to put my text into html format
- Limitation of numbers of characters by 2000 so i can only use Firefox for browser
So I don't have any idea to find something more optimized because I have an html format kinda complexe for the content of my mail and I need to allow preview a mail.
Thank you for your help,
Zeely
Sep 18, 2024 04:06 AM
Hi Zeely,
It sounds like you're trying to offer a way for users to preview emails in HTML format via Outlook before they send them, but you're hitting some limitations with the `mailto:` approach, particularly the lack of HTML support and character limits.
### Here are a couple of alternative approaches that might help you achieve this:
### 1. **Create a Draft Email in Outlook Using a Script (VBA or Office Script)**
Instead of using `mailto:`, you can use **Outlook VBA** or **Office Script** to programmatically create an email draft that will open in Outlook with the content, including HTML formatting. Users can then preview, edit, and send the email themselves.
Here's an example VBA code that creates an HTML email draft:
```vba
Sub CreateDraftEmail()
Dim olApp As Outlook.Application
Dim olMail As Outlook.MailItem
Set olApp = CreateObject("Outlook.Application")
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = "recipient@example.com"
.Subject = "Email Subject"
.HTMLBody = "<html><body><h1>Hello!</h1><p>This is a test email.</p></body></html>"
.Display 'This opens the email in draft mode
End With
End Sub
```
This code opens the email in the Outlook editor with the provided HTML content, and the user can manually review it before sending.
### 2. **Use an External Email API for Preview**
Another option is to use an email API service, like **SendGrid**, **Mailgun**, or **SMTP**, where you can first generate the email in HTML format and send a preview of it to Outlook or any other email client.
- You can generate the email content and send it to the user’s inbox for review.
- Users can open the email, review it, and then decide whether to forward it or use an Outlook add-in to approve and send it.
### 3. **Embed an Email Preview in Your Interface**
If you're using a web interface, you can create an HTML email preview inside the interface itself. This would involve:
- Generating the HTML email content based on the user input.
- Rendering the email as a preview directly in the browser before sending it.
After the preview is confirmed, you can use an API or Outlook integration to send the actual email.
### 4. **Automate HTML Formatting via Macro**
You mentioned you already have a macro to convert the text to HTML. You can expand on this to dynamically create the email and open it as a draft for preview. Since Outlook VBA has no character limit, this method should solve your `mailto:` limitations.
### Final Thoughts
The VBA or Office Script method should be the most direct and seamless if you are working within Outlook. It gives you full control over HTML formatting, and the email is opened for the user to preview and manually send.
Let me know if you need more details on any of these methods or have additional questions!