Send ICS file via SMTP not correctly displayed in Outlook?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}
I'm trying to send calendar invites from my backend server.
Here is the function involved :
fun sendEventInvite(to: String, subject: String, text: String) {
val message: MimeMessage = emailSender.createMimeMessage()
message.setRecipient(Message.RecipientType.TO, InternetAddress(to))
message.subject = subject
val messageBodyText = MimeBodyPart()
messageBodyText.setText(text)
val messageBodyEvent = MimeBodyPart()
messageBodyEvent.dataHandler = ByteArrayDataSource(createEvent(), "text/calendar")
val multiPart = MimeMultipart()
multiPart.addBodyPart(messageBodyEvent)
message.setContent(multiPart)
emailSender.send(message)
}
And here is how I format the ICS file:
fun createEvent(): String{
return "BEGIN:VCALENDARn" +
"VERSION:2.0n" +
"PRODID:-//GRTgaz Corporation//NONSGML Togaz'er//FRn" +
"METHOD:REQUESTn" +
"BEGIN:VEVENTn" +
"UID:d8f5a0777-bf6d-25d2-f14a-52e7fe3df810n" +
"DTSTAMP:20181119T105044Zn" +
"ORGANIZER;CN=Baptiste Arnaud:MAILTO:baptiste.arnaud95@gmail.comn" +
"DTSTART:20181120T150000n" +
"DTEND:20181120T153000n" +
"SUMMARY:Descriptionn" +
"END:VEVENTn" +
"END:VCALENDARn")
}
This file content is supposed to work because it is exactly the same of a working example. So the problem comes from mail headers ? But I'm not sure what's missing.
How it should works:
But it's displayed like this:
java spring-boot outlook javamail icalendar
add a comment |
I'm trying to send calendar invites from my backend server.
Here is the function involved :
fun sendEventInvite(to: String, subject: String, text: String) {
val message: MimeMessage = emailSender.createMimeMessage()
message.setRecipient(Message.RecipientType.TO, InternetAddress(to))
message.subject = subject
val messageBodyText = MimeBodyPart()
messageBodyText.setText(text)
val messageBodyEvent = MimeBodyPart()
messageBodyEvent.dataHandler = ByteArrayDataSource(createEvent(), "text/calendar")
val multiPart = MimeMultipart()
multiPart.addBodyPart(messageBodyEvent)
message.setContent(multiPart)
emailSender.send(message)
}
And here is how I format the ICS file:
fun createEvent(): String{
return "BEGIN:VCALENDARn" +
"VERSION:2.0n" +
"PRODID:-//GRTgaz Corporation//NONSGML Togaz'er//FRn" +
"METHOD:REQUESTn" +
"BEGIN:VEVENTn" +
"UID:d8f5a0777-bf6d-25d2-f14a-52e7fe3df810n" +
"DTSTAMP:20181119T105044Zn" +
"ORGANIZER;CN=Baptiste Arnaud:MAILTO:baptiste.arnaud95@gmail.comn" +
"DTSTART:20181120T150000n" +
"DTEND:20181120T153000n" +
"SUMMARY:Descriptionn" +
"END:VEVENTn" +
"END:VCALENDARn")
}
This file content is supposed to work because it is exactly the same of a working example. So the problem comes from mail headers ? But I'm not sure what's missing.
How it should works:
But it's displayed like this:
java spring-boot outlook javamail icalendar
add a comment |
I'm trying to send calendar invites from my backend server.
Here is the function involved :
fun sendEventInvite(to: String, subject: String, text: String) {
val message: MimeMessage = emailSender.createMimeMessage()
message.setRecipient(Message.RecipientType.TO, InternetAddress(to))
message.subject = subject
val messageBodyText = MimeBodyPart()
messageBodyText.setText(text)
val messageBodyEvent = MimeBodyPart()
messageBodyEvent.dataHandler = ByteArrayDataSource(createEvent(), "text/calendar")
val multiPart = MimeMultipart()
multiPart.addBodyPart(messageBodyEvent)
message.setContent(multiPart)
emailSender.send(message)
}
And here is how I format the ICS file:
fun createEvent(): String{
return "BEGIN:VCALENDARn" +
"VERSION:2.0n" +
"PRODID:-//GRTgaz Corporation//NONSGML Togaz'er//FRn" +
"METHOD:REQUESTn" +
"BEGIN:VEVENTn" +
"UID:d8f5a0777-bf6d-25d2-f14a-52e7fe3df810n" +
"DTSTAMP:20181119T105044Zn" +
"ORGANIZER;CN=Baptiste Arnaud:MAILTO:baptiste.arnaud95@gmail.comn" +
"DTSTART:20181120T150000n" +
"DTEND:20181120T153000n" +
"SUMMARY:Descriptionn" +
"END:VEVENTn" +
"END:VCALENDARn")
}
This file content is supposed to work because it is exactly the same of a working example. So the problem comes from mail headers ? But I'm not sure what's missing.
How it should works:
But it's displayed like this:
java spring-boot outlook javamail icalendar
I'm trying to send calendar invites from my backend server.
Here is the function involved :
fun sendEventInvite(to: String, subject: String, text: String) {
val message: MimeMessage = emailSender.createMimeMessage()
message.setRecipient(Message.RecipientType.TO, InternetAddress(to))
message.subject = subject
val messageBodyText = MimeBodyPart()
messageBodyText.setText(text)
val messageBodyEvent = MimeBodyPart()
messageBodyEvent.dataHandler = ByteArrayDataSource(createEvent(), "text/calendar")
val multiPart = MimeMultipart()
multiPart.addBodyPart(messageBodyEvent)
message.setContent(multiPart)
emailSender.send(message)
}
And here is how I format the ICS file:
fun createEvent(): String{
return "BEGIN:VCALENDARn" +
"VERSION:2.0n" +
"PRODID:-//GRTgaz Corporation//NONSGML Togaz'er//FRn" +
"METHOD:REQUESTn" +
"BEGIN:VEVENTn" +
"UID:d8f5a0777-bf6d-25d2-f14a-52e7fe3df810n" +
"DTSTAMP:20181119T105044Zn" +
"ORGANIZER;CN=Baptiste Arnaud:MAILTO:baptiste.arnaud95@gmail.comn" +
"DTSTART:20181120T150000n" +
"DTEND:20181120T153000n" +
"SUMMARY:Descriptionn" +
"END:VEVENTn" +
"END:VCALENDARn")
}
This file content is supposed to work because it is exactly the same of a working example. So the problem comes from mail headers ? But I'm not sure what's missing.
How it should works:
But it's displayed like this:
java spring-boot outlook javamail icalendar
java spring-boot outlook javamail icalendar
edited Nov 20 '18 at 12:23
Baptiste Arnaud
asked Nov 16 '18 at 15:12
Baptiste ArnaudBaptiste Arnaud
7791826
7791826
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
All of the calls to addHeaderLine are not valid MIME headers so I don't know what you're trying to accomplish with that.
The use of MimeHelper is just confusing things. Call the corresponding methods on the MimeMessage object directly, and add "text" as the first MimeBodyPart in the multipart, before the ics attachment.
I did what you told me here, but it didn't fix the problem (my question is edited if you want to take a look again). Does the problem can be related to the account used to send emails? Because I use the gmail smtp server. Maybe it's related to the problem.
– Baptiste Arnaud
Nov 19 '18 at 10:01
The code looks better. Compare the MIME content of the message that works correctly with the MIME content of the message you're creating. You can see the MIME content of the message you're sending in the JavaMail debug output.
– Bill Shannon
Nov 19 '18 at 17:53
BTW, in eventIcs, the explicit use of StringBuffer isn't helping at all. You might as well just construct a String object using concatenation ("+"). As it is, you're constructing the String and then appending that one String to the StringBuffer.
– Bill Shannon
Nov 19 '18 at 17:56
I found the solution, a REQUEST header was missing :messageBodyEvent.dataHandler = ByteArrayDataSource(createEvent(), "text/calendar; method=REQUEST")
. It totally worked with gmail smtp server. But now I'm using my company's credentials logged in an outlook server and It throws a weird error :STOREDRV.Submission.Exception:InvalidRecipientsException; Failed to process message due to a permanent exception with message A message can't be sent because it contains no recipients.
... Whenever I remove the REQUEST header it sends the mail correctly. What's wrong ?
– Baptiste Arnaud
Nov 20 '18 at 16:16
It would be better to post a new question for the new problem. The JavaMail debug output might help us figure out what's wrong.
– Bill Shannon
Nov 20 '18 at 21:04
|
show 1 more comment
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53340539%2fsend-ics-file-via-smtp-not-correctly-displayed-in-outlook%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
All of the calls to addHeaderLine are not valid MIME headers so I don't know what you're trying to accomplish with that.
The use of MimeHelper is just confusing things. Call the corresponding methods on the MimeMessage object directly, and add "text" as the first MimeBodyPart in the multipart, before the ics attachment.
I did what you told me here, but it didn't fix the problem (my question is edited if you want to take a look again). Does the problem can be related to the account used to send emails? Because I use the gmail smtp server. Maybe it's related to the problem.
– Baptiste Arnaud
Nov 19 '18 at 10:01
The code looks better. Compare the MIME content of the message that works correctly with the MIME content of the message you're creating. You can see the MIME content of the message you're sending in the JavaMail debug output.
– Bill Shannon
Nov 19 '18 at 17:53
BTW, in eventIcs, the explicit use of StringBuffer isn't helping at all. You might as well just construct a String object using concatenation ("+"). As it is, you're constructing the String and then appending that one String to the StringBuffer.
– Bill Shannon
Nov 19 '18 at 17:56
I found the solution, a REQUEST header was missing :messageBodyEvent.dataHandler = ByteArrayDataSource(createEvent(), "text/calendar; method=REQUEST")
. It totally worked with gmail smtp server. But now I'm using my company's credentials logged in an outlook server and It throws a weird error :STOREDRV.Submission.Exception:InvalidRecipientsException; Failed to process message due to a permanent exception with message A message can't be sent because it contains no recipients.
... Whenever I remove the REQUEST header it sends the mail correctly. What's wrong ?
– Baptiste Arnaud
Nov 20 '18 at 16:16
It would be better to post a new question for the new problem. The JavaMail debug output might help us figure out what's wrong.
– Bill Shannon
Nov 20 '18 at 21:04
|
show 1 more comment
All of the calls to addHeaderLine are not valid MIME headers so I don't know what you're trying to accomplish with that.
The use of MimeHelper is just confusing things. Call the corresponding methods on the MimeMessage object directly, and add "text" as the first MimeBodyPart in the multipart, before the ics attachment.
I did what you told me here, but it didn't fix the problem (my question is edited if you want to take a look again). Does the problem can be related to the account used to send emails? Because I use the gmail smtp server. Maybe it's related to the problem.
– Baptiste Arnaud
Nov 19 '18 at 10:01
The code looks better. Compare the MIME content of the message that works correctly with the MIME content of the message you're creating. You can see the MIME content of the message you're sending in the JavaMail debug output.
– Bill Shannon
Nov 19 '18 at 17:53
BTW, in eventIcs, the explicit use of StringBuffer isn't helping at all. You might as well just construct a String object using concatenation ("+"). As it is, you're constructing the String and then appending that one String to the StringBuffer.
– Bill Shannon
Nov 19 '18 at 17:56
I found the solution, a REQUEST header was missing :messageBodyEvent.dataHandler = ByteArrayDataSource(createEvent(), "text/calendar; method=REQUEST")
. It totally worked with gmail smtp server. But now I'm using my company's credentials logged in an outlook server and It throws a weird error :STOREDRV.Submission.Exception:InvalidRecipientsException; Failed to process message due to a permanent exception with message A message can't be sent because it contains no recipients.
... Whenever I remove the REQUEST header it sends the mail correctly. What's wrong ?
– Baptiste Arnaud
Nov 20 '18 at 16:16
It would be better to post a new question for the new problem. The JavaMail debug output might help us figure out what's wrong.
– Bill Shannon
Nov 20 '18 at 21:04
|
show 1 more comment
All of the calls to addHeaderLine are not valid MIME headers so I don't know what you're trying to accomplish with that.
The use of MimeHelper is just confusing things. Call the corresponding methods on the MimeMessage object directly, and add "text" as the first MimeBodyPart in the multipart, before the ics attachment.
All of the calls to addHeaderLine are not valid MIME headers so I don't know what you're trying to accomplish with that.
The use of MimeHelper is just confusing things. Call the corresponding methods on the MimeMessage object directly, and add "text" as the first MimeBodyPart in the multipart, before the ics attachment.
answered Nov 16 '18 at 19:07
Bill ShannonBill Shannon
24.1k53134
24.1k53134
I did what you told me here, but it didn't fix the problem (my question is edited if you want to take a look again). Does the problem can be related to the account used to send emails? Because I use the gmail smtp server. Maybe it's related to the problem.
– Baptiste Arnaud
Nov 19 '18 at 10:01
The code looks better. Compare the MIME content of the message that works correctly with the MIME content of the message you're creating. You can see the MIME content of the message you're sending in the JavaMail debug output.
– Bill Shannon
Nov 19 '18 at 17:53
BTW, in eventIcs, the explicit use of StringBuffer isn't helping at all. You might as well just construct a String object using concatenation ("+"). As it is, you're constructing the String and then appending that one String to the StringBuffer.
– Bill Shannon
Nov 19 '18 at 17:56
I found the solution, a REQUEST header was missing :messageBodyEvent.dataHandler = ByteArrayDataSource(createEvent(), "text/calendar; method=REQUEST")
. It totally worked with gmail smtp server. But now I'm using my company's credentials logged in an outlook server and It throws a weird error :STOREDRV.Submission.Exception:InvalidRecipientsException; Failed to process message due to a permanent exception with message A message can't be sent because it contains no recipients.
... Whenever I remove the REQUEST header it sends the mail correctly. What's wrong ?
– Baptiste Arnaud
Nov 20 '18 at 16:16
It would be better to post a new question for the new problem. The JavaMail debug output might help us figure out what's wrong.
– Bill Shannon
Nov 20 '18 at 21:04
|
show 1 more comment
I did what you told me here, but it didn't fix the problem (my question is edited if you want to take a look again). Does the problem can be related to the account used to send emails? Because I use the gmail smtp server. Maybe it's related to the problem.
– Baptiste Arnaud
Nov 19 '18 at 10:01
The code looks better. Compare the MIME content of the message that works correctly with the MIME content of the message you're creating. You can see the MIME content of the message you're sending in the JavaMail debug output.
– Bill Shannon
Nov 19 '18 at 17:53
BTW, in eventIcs, the explicit use of StringBuffer isn't helping at all. You might as well just construct a String object using concatenation ("+"). As it is, you're constructing the String and then appending that one String to the StringBuffer.
– Bill Shannon
Nov 19 '18 at 17:56
I found the solution, a REQUEST header was missing :messageBodyEvent.dataHandler = ByteArrayDataSource(createEvent(), "text/calendar; method=REQUEST")
. It totally worked with gmail smtp server. But now I'm using my company's credentials logged in an outlook server and It throws a weird error :STOREDRV.Submission.Exception:InvalidRecipientsException; Failed to process message due to a permanent exception with message A message can't be sent because it contains no recipients.
... Whenever I remove the REQUEST header it sends the mail correctly. What's wrong ?
– Baptiste Arnaud
Nov 20 '18 at 16:16
It would be better to post a new question for the new problem. The JavaMail debug output might help us figure out what's wrong.
– Bill Shannon
Nov 20 '18 at 21:04
I did what you told me here, but it didn't fix the problem (my question is edited if you want to take a look again). Does the problem can be related to the account used to send emails? Because I use the gmail smtp server. Maybe it's related to the problem.
– Baptiste Arnaud
Nov 19 '18 at 10:01
I did what you told me here, but it didn't fix the problem (my question is edited if you want to take a look again). Does the problem can be related to the account used to send emails? Because I use the gmail smtp server. Maybe it's related to the problem.
– Baptiste Arnaud
Nov 19 '18 at 10:01
The code looks better. Compare the MIME content of the message that works correctly with the MIME content of the message you're creating. You can see the MIME content of the message you're sending in the JavaMail debug output.
– Bill Shannon
Nov 19 '18 at 17:53
The code looks better. Compare the MIME content of the message that works correctly with the MIME content of the message you're creating. You can see the MIME content of the message you're sending in the JavaMail debug output.
– Bill Shannon
Nov 19 '18 at 17:53
BTW, in eventIcs, the explicit use of StringBuffer isn't helping at all. You might as well just construct a String object using concatenation ("+"). As it is, you're constructing the String and then appending that one String to the StringBuffer.
– Bill Shannon
Nov 19 '18 at 17:56
BTW, in eventIcs, the explicit use of StringBuffer isn't helping at all. You might as well just construct a String object using concatenation ("+"). As it is, you're constructing the String and then appending that one String to the StringBuffer.
– Bill Shannon
Nov 19 '18 at 17:56
I found the solution, a REQUEST header was missing :
messageBodyEvent.dataHandler = ByteArrayDataSource(createEvent(), "text/calendar; method=REQUEST")
. It totally worked with gmail smtp server. But now I'm using my company's credentials logged in an outlook server and It throws a weird error :STOREDRV.Submission.Exception:InvalidRecipientsException; Failed to process message due to a permanent exception with message A message can't be sent because it contains no recipients.
... Whenever I remove the REQUEST header it sends the mail correctly. What's wrong ?– Baptiste Arnaud
Nov 20 '18 at 16:16
I found the solution, a REQUEST header was missing :
messageBodyEvent.dataHandler = ByteArrayDataSource(createEvent(), "text/calendar; method=REQUEST")
. It totally worked with gmail smtp server. But now I'm using my company's credentials logged in an outlook server and It throws a weird error :STOREDRV.Submission.Exception:InvalidRecipientsException; Failed to process message due to a permanent exception with message A message can't be sent because it contains no recipients.
... Whenever I remove the REQUEST header it sends the mail correctly. What's wrong ?– Baptiste Arnaud
Nov 20 '18 at 16:16
It would be better to post a new question for the new problem. The JavaMail debug output might help us figure out what's wrong.
– Bill Shannon
Nov 20 '18 at 21:04
It would be better to post a new question for the new problem. The JavaMail debug output might help us figure out what's wrong.
– Bill Shannon
Nov 20 '18 at 21:04
|
show 1 more comment
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53340539%2fsend-ics-file-via-smtp-not-correctly-displayed-in-outlook%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown