Mail sent with sp_send_dbmail shows embedded images as attachments - sql-server

I'm using sp_send_dbmail to send a "welcome" email to employees' newly provisioned mailboxes. The content looks good in both Outlook 2016 and in Office365.
There is a difference from the source email I'm replicating, however, in the how the attachments appear. The source email does not show a paperclip icon or attachments in either system. The email sent with sp_send_dbmail shows the paperclip in both and lists attachments in Office365 (but not in Outlook).
I copied the HTML from the source email in Outlook and had to change the src tags to get it to work:
<img ... src="cid:image009.png#01D42E2D.8043A5B0">
This wouldn't show the images until I removed the #01D42E2D.8043A5B0. I haven't been able to find any explanation of what that part of the tag does or how to use it properly.
Is there a way to make the message sent with sp_send_dbmail appear exactly as the original does?
Edit to add:
Further testing finds that TypeApp (an Android mail client) doesn't render the images from sp_send_dbmail, but it does display the source email correctly.
I realize that email clients won't behave consistently, but why can't I make the email I send behave like the other?

A possible workaround is to use SendGrid email. It might work differently with embedded images. Not sure.
In a previous project I hit a lot of various problems with our internal Exchange server, so I just went outside to SendGrid, which worked very well. They have a free tier.

Related

Remove "[External]" tags added by email server

My organization has begun adding obnoxious warnings to the subject and body of any email that arrives from an external address. My organization allows email forwarding, and I forward to gmail. I would like to have the extra text automatically removed before I see them in gmail. This would not violate the policies at my organization. Some ideas I had:
(1) One option would be to set up a gmail filter that edits the message. This feature does not seem to exist.
(2) Another option would be to customize the display so that this particular text is never shown on the screen. Again, there seems to be no way to do this.
(3) I wrote a script in Google Apps to grab to the content of each offending email and send an edited version to myself, but there is no way to make the "from" field show the original sender (perhaps with good reason). I can put that information in "reply to" but the gmail client doesn't show it nicely. This removes the annoying extra text at the cost of the ability to easily see who sent the email. The core of it is this call:
GmailApp.sendEmail("<my_email_address>",newSubject,newBody,{
attachments: message.getAttachments(),
bcc: message.getBcc(),
cc: message.getCc(),
htmlBody: newBody,
replyTo: message.getFrom(),
});
Any ideas? This is becoming a big problem as the "nanny state" approaches, so I'm sure others will appreciate your solution.
Issue
It unfortunately seems that at the day of this post, there is no way of edditing a forwarded email with the Gmail API. Check the documentation to see what you can actually do with the Gmail API in regards to forwarding email addresses.
Workaround
Despite it is not possible to edit a forwarding email address, in your case you are interested in:
Edit the body and subject of the email address.
Preserve the information of who the sender was.
Therefore what you could do is:
Get the email address you want to edit. Get the body, subject and information about who was sending it and store that.
Create a new message where you edit the message you just got and write on the subject the from field that was in the message you just got.
Send that created message to your desired recipient just like it was a forwarding email.
I hope this has helped you. Let me know if you need anything else or if you did not understood something. :)
Apps Script
You can insert messages into your inbox with their original "From" field but a modified body.
Note: Inserting is different from sending because the message is created on the inbox with less validation than sending.
To use this on Apps Script, take a look at the Advanced Gmail Service.
Custom Application
Another idea on how to do this is to use a custom application (in any language you'd prefer) that:
scans your company inbox with IMAP
manipulates the message body to remove the artifacts you don't want
insert manipulated message into your Gmail inbox with the Gmail API

Open Gmail Client With File Already Attached

I see you can send emails with uploaded attachments using the Google Gmail API. However, I want the user to be able to preview the email before sending. It looks like there isn't a way to do this?
So essentially would the only solution be to create my own simple email client, then send the email through the API? Or would using the API even be necessary as in that case I could just use the server's native sendmail client to sent out the email with the user's gmail address as the return address.
I guess using the API, the advantage is the email would appear in the user's SENT folder.
Unfortunately, I don't think there's a live preview that's available in a way you intended. As far as I know, Outlook (for reference) doesn't even have it. What they have is to upload the attachments while the mail is still being drafted.
The best I can think of is once the message will be sent, save it as draft at first and retrieve the mail again on the succeeding page. This will look like a preview that you intended. Once done, you can then finally send the drafted email to the receipients.

Capturing Responses from iCal/ics file

I am generating ics/iCal files for events in a Web app and emailing them to users to add to their calendars. This part works great
I would like to require a response in the ics files and then capture their responses. I was under the impression I can specify a URL to my Web app in the ics file. Then I can parse the email and attendee status from the response format.
Is something like this possible? I can't find any ics documentation to handle something like this.
Thanks!
Unfortunately, this is not possible. It's possible to specify in an iCalendar object that a user should respond, (by using the relevant parameters in the ATTENDEE property), but the result will be sent back as an e-mail response.
unless the receiving user runs a caldav server with scheduling support.

Email to automatically add calendar reminder to their calendars

Is there a way to send mass email and automatically add a calendar reminder the users' calendars? I've found you can export an .ics file and link to that where users can import into their program of choice, but what about something that will do it automatically to any calendar? I've used this article to follow, but nothing for automatically adding to the user's calendar nor do we use that email service.
http://www.whatcounts.com/2013/07/feature-friday-add-calendar-events-in-publicaster-edition/
You can not force someone to automatically download the .ics, as you can imagine, auto downloading anything in email would pose a security risk to the reader.
All you can do is host the .ics (or any file really) on the web and hyperlink to it with a 'Save to Calendar' type linkin your email.
I believe there is no way to do this automatically. One of the important reason is JavaScript is not allowed by most of the email client.
I think the best way to show user a event and make it easy to add to their calendar is generate a .ics file and attach to the email as an attachment. Many email client, like Gmail, will find it and display it as a part of the email.
Here is a reference of .ics file format http://en.wikipedia.org/wiki/ICalendar

Testing Text-Based Emails

I am using Google AppEngine API to send an email to my application's users. The email fields accepts html and body, where the former is the HTML version of the email and the latter is the plain text form. I can easily test the HTML version (to see how it looks) by sending an email to myself. But I am wondering how I can test the plain text version if all of the email providers nowadays are HTML based?
Send an email to yourself, then view the source. In GMail, for instance, you do this by clicking on the down arrow in the upper right corner of the message, then clicking "Show Original".

Resources