I am generating emails using Spring JavaMail and Velocity Template to send to the customer.I have to store these outgoing Emails into some folder in .MSG format.I did so much research on the web.But not able to find right Java API to do this.And in Spring Java Mail I am not able to find writeTO() method which is in JavaX.mail API.Can some one help me with this issue.
You already found that javax.mail.Part has a writeTo method.
So what you need is a way to "convert" a spring simple mail to an javax.mail
It should work more or less this way:
org.springframework.mail.javamail.MimeMailMessage message
message = new MimeMailMessage(new SmartMimeMessage(getSession(),
getDefaultEncoding(),
getDefaultFileTypeMap()));
yourSimpleMessage.copyTo(message);
javax.mail.internet.MimeMessage result = message.getMimeMessage());
result.writeTo(yourOutputStream);
Related
I am trying to integrate Swagger in my existing application for REST APIs.
While running on localhost I am getting the expected result in Swagger UI.
But when I deploy my .war file on DAP and try to access it is not able to read the JSON from the URL.
{"schemaValidationMessages":[{"level":"error","message":Cant read from file..
I suppose this is a validator issue.
I cannot make the link public as I work for a bank and it has to be private and secure at any cost.
Alternately I tried to bypass the validator.
I have already tried setting validatorUrl = null in my index.html.
Also i have set validatorUrl = null in my swagger-ui.js file.
Both these don't seem to work.
Can any one please guide me on how can I go about doing this as this is really important and critical.
I want to send PDFs via camel route to an ActiveMQ queue.
I need to extract these PDFs in another camel route.
Im not able to extract the data from the queue. I also tried it with .marshal().base64(). The Data reaches the Message Broker but I can't extract it.
Following Error will appear:
Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/util/backoff/BackOff
at org.apache.camel.component.jms.JmsConfiguration.chooseMessageListenerContainerImplementation(JmsConfiguration.java:466)
at org.apache.camel.component.jms.JmsConfiguration.createMessageListenerContainer(JmsConfiguration.java:456).....
Does anybody has an idea?
The Object is org.apache.camel.converter.stream.InputStreamCache when using base64 marshalling.
The Object is org.apache.camel.component.file.GenericFile when just sending the pdf to the queue.
How can I extract the data to get that PDF back?
Here is the Code to deliver two different queues. But I can't extract data even of one.
from("file:src/main/resources/test?noop=true")
.to("jms:queue:PDF")
.marshal().base64()
.to("jms:queue:BASE64_PDF")
this example works well
from("file:src/main/resources/test?noop=true")
.to("jms:queue:PDF");
from("jms:queue:PDF")
.to("file:src/main/resources/testReceive");
it is dependencies problem not Camel, verify that you have spring-core-x.x.x.jar or activemq-all-x.x.jar in the classpath
I want to send some json to hipchat upon error. well raw json is not very readable in the hipchat.
the hipchat client support /code and I want to have similar output using the API. i tried many ways (I already implemented one library in php that using the same class and html element that /code is generating and send it to the API) but it comes with it's own problems.
first the API has 100,000 character limit. there was some cases that my pretty print exceeded the limit(bcs of adding many html and css to the message).
also it's not easy to port it to other project. I created that library in PHP, now i want to integrate a .netCore application and I need to write the whole things again.
[Update 1]
it turned out that hipchat API support this by setting the header as Content-Type:text/plain and send the content with /code in front of the message
/code {yourcontent}
this way message will with color yellow. is there any way to set the color?
I could achieve this by sending json and setting "message_format":"text" previously it was set to html, that's why /code didn't work before
When trying to set the start time zone of an appointment (in ews java API 1.1.5) I get an error. I'm trying to set the time zone because an exception is raised when using appointment.setStart otherwise.
Appointment = new Appointment(service);
appointment.setStartTimeZone(new TimeZoneDefinition() {{setId("what should go hère")}});
appointment.setStart(startTime);....
Using exchange 2007
It finally appear that the JAVA EWS API is a bad (and full of bugs) port of the C# version.
So the rule is simply to not use it.
There is some alternative out there :
J-xchange
For my specific question, it looks like setStartTimeZone function expect a C# object, which it's not possible to get.
I was able to get around this by commenting out the validation code regarding StartTimeZone (lines 247-256 of Appointment.java) and recompiling the jar. If I pass in date/times based on UTC, the appointment gets created in the user's timezone.
hi i am monitoring jvm and i am getting it statics like memory,number of threads etc
and i want to generate mail notification depending on that conditions. can any give me some sample code on how to generate mails
The JavaMail download contains examples for how to use the javax.mail API:
http://java.sun.com/products/javamail/FAQ.html#examples
Look at the demo folder in the javamail-1.4.2.zip
Another approach would be to use log4j or another logging framework that supports an "Smtp/Email" appender. See the log4j site for examples on how to setup email logging.