ical4J: make Outlook appointment info and actions display in emails - jakarta-mail

I am using ical4j (version 3.0.1) to send an email to an Outlook email address (Office 365). Here is what I see in an email:
You can see the Calendar.ics attachment and clicking on the down arrow allows you to add the event to your Outlook calendar. This works, but not good as the following one.
When I create an appointment in Outlook for someone, I can directly see the appointment info and action buttons (Accept, etc.) in the email, as shown below.
How can I do it through ical4j?
Update 1:
Due to Arnaud's input, I have made my code work by adding the following line:
icsCalendar.getProperties().add(Method.REQUEST);
and updating this link:
messageBodyPart.setDataHandler(new DataHandler(new ByteArrayDataSource(icsCalendar.toString(), "text/calendar; charset=\"utf-8\"; method=REQUEST")));

Your description does not include the icalendar stream so it is not possible to check whether all mandatory properties are present in the invitation.
Assuming that everything is fine with the REQUEST, you must then follow certain rules when constructing your email message. See Multipart email with text and calendar: Outlook doesn't recognize ics

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

Mail sent with sp_send_dbmail shows embedded images as attachments

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.

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

Can I use Contact Form DB plugin in my wordpress site for saving and displaying data without sending emails

I want to create a wordpress custom plugin for saving three fields of data and also an image of the same from wp-admin area for every item. It should be able to display all these items in a page.
When I searched for a plugin I found Contact Form DB plugin which can be used as contact form 7 plugin extension for saving data send through it..
http://wordpress.org/extend/plugins/contact-form-7-to-database-extension/
Can I use Contact Form DB plugin in my wordpress site for saving and displaying data without sending emails? It also sends email but I only want to store and display data.
Another problem:- I'm already using a contact form from contact form 7 plugin for sending email enquiries.. Will the changes for saving data in contact form 7 affect its working?
Please help me with any reference or solution as I'm new to wordpress and currently don't know about plugin development.
Any help will be greatly appreciated..
Thanks in advance.
You can use wpcf7_before_send_mail action hook to prevent form being sent to email..
(I have tested this with "Contact Form DB" plugin - it saves data before email is filtered)
To filter only specific Form IDs - use something like this:
function wpcf7_skip_email_sending($wpcf7_data)
{
if ( in_array($wpcf7_data->id(), array(2,3,7)) ) {
$wpcf7_data->skip_mail = true;
}
}
add_action("wpcf7_before_send_mail", "wpcf7_skip_email_sending");
(For older CF7 version you might have to change $wpcf7_data->id() to $wpcf7_data->id)
If you setup the Contact form 7 and put in a junk or noreply email address to send the message to on Contact form 7 it will still log the message being sent in the contact form DB
So in the shortcode template send message to junk#yourdomain.com and whenever a user submits it will try to send to that email and will still log the email as being sent. Personally I would actually create that email address so that your smtp doesn't get flooded with bounce back from smtp server.
To avoid sending emails, without even touching the files, the fastest way is to add in the additional settings tab
demo_mode: on
or
skip_mail: on
With Contact Form DB both works fine. The difference is that demo_mode won't work with Flamingo.

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