本文整理了Java中javax.mail.internet.MimeMessage.writeTo()
方法的一些代码示例,展示了MimeMessage.writeTo()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MimeMessage.writeTo()
方法的具体详情如下:
包路径:javax.mail.internet.MimeMessage
类名称:MimeMessage
方法名:writeTo
[英]Output the message as an RFC 822 format stream.
Note that, depending on how the messag was constructed, it may use a variety of line termination conventions. Generally the output should be sent through an appropriate FilterOutputStream that converts the line terminators to the desired form, either CRLF for MIME compatibility and for use in Internet protocols, or the local platform's line terminator for storage in a local text file.
This implementation calls the writeTo(OutputStream, String[])
method with a null ignore list.
[中]以RFC 822格式流输出消息。
请注意,根据messag的构造方式,它可能会使用多种线路终止约定。通常,输出应通过适当的FilterOutputStream发送,该FilterOutputStream将行终止符转换为所需格式,CRLF用于MIME兼容性并用于Internet协议,或者本地平台的行终止符用于存储在本地文本文件中。
此实现使用null ignore list调用writeTo(OutputStream, String[])
方法。
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Output the message as an RFC 822 format stream. <p>
*
* Note that, depending on how the messag was constructed, it may
* use a variety of line termination conventions. Generally the
* output should be sent through an appropriate FilterOutputStream
* that converts the line terminators to the desired form, either
* CRLF for MIME compatibility and for use in Internet protocols,
* or the local platform's line terminator for storage in a local
* text file. <p>
*
* This implementation calls the <code>writeTo(OutputStream,
* String[])</code> method with a null ignore list.
*
* @exception IOException if an error occurs writing to the stream
* or if an error is generated by the
* javax.activation layer.
* @exception MessagingException for other failures
* @see javax.activation.DataHandler#writeTo
*/
public void writeTo(OutputStream os)
throws IOException, MessagingException {
writeTo(os, null);
}
代码示例来源:origin: com.sun.mail/javax.mail
/**
* Output the message as an RFC 822 format stream. <p>
*
* Note that, depending on how the messag was constructed, it may
* use a variety of line termination conventions. Generally the
* output should be sent through an appropriate FilterOutputStream
* that converts the line terminators to the desired form, either
* CRLF for MIME compatibility and for use in Internet protocols,
* or the local platform's line terminator for storage in a local
* text file. <p>
*
* This implementation calls the <code>writeTo(OutputStream,
* String[])</code> method with a null ignore list.
*
* @exception IOException if an error occurs writing to the stream
* or if an error is generated by the
* javax.activation layer.
* @exception MessagingException for other failures
* @see javax.activation.DataHandler#writeTo
*/
@Override
public void writeTo(OutputStream os)
throws IOException, MessagingException {
writeTo(os, null);
}
代码示例来源:origin: camunda/camunda-bpm-platform
/**
* Write out the bytes into the given OutputStream.
*/
public void writeTo(OutputStream os)
throws IOException, MessagingException {
if (bodyLoaded) {
super.writeTo(os);
return;
}
InputStream is = getMimeStream();
try {
// write out the bytes
byte[] bytes = new byte[16*1024];
int count;
while ((count = is.read(bytes)) != -1)
os.write(bytes, 0, count);
} finally {
is.close();
}
}
代码示例来源:origin: com.sun.mail/javax.mail
/**
* Write out the bytes into the given OutputStream.
*/
@Override
public void writeTo(OutputStream os)
throws IOException, MessagingException {
if (bodyLoaded) {
super.writeTo(os);
return;
}
InputStream is = getMimeStream();
try {
// write out the bytes
byte[] bytes = new byte[16*1024];
int count;
while ((count = is.read(bytes)) != -1)
os.write(bytes, 0, count);
} finally {
is.close();
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
mimeMessage.writeTo(fos);
fos.flush();
fos.close();
代码示例来源:origin: magefree/mage
public static boolean sendMessage(String email, String subject, String text) {
if (email.isEmpty()) {
logger.info("Email is not sent because the address is empty");
return false;
}
try {
Gmail gmail = new Builder(httpTransport, JSON_FACTORY, credential).setApplicationName("XMage Server").build();
MimeMessage mimeMessage = new MimeMessage(Session.getDefaultInstance(new Properties()));
mimeMessage.addRecipient(javax.mail.Message.RecipientType.TO, new InternetAddress(email));
mimeMessage.setSubject(subject);
mimeMessage.setText(text);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
mimeMessage.writeTo(baos);
Message message = new Message();
message.setRaw(Base64.encodeBase64URLSafeString(baos.toByteArray()));
gmail.users().messages().send(ConfigSettings.instance.getGoogleAccount()
+ (ConfigSettings.instance.getGoogleAccount().endsWith("@gmail.com") ? "" : "@gmail.com"), message).execute();
return true;
} catch (MessagingException | IOException ex) {
logger.error("Error sending message", ex);
}
return false;
}
}
代码示例来源:origin: camunda/camunda-bpm-platform
try {
strict = source.strict;
source.writeTo(bos);
bos.close();
SharedByteArrayInputStream bis =
代码示例来源:origin: com.sun.mail/javax.mail
try {
strict = source.strict;
source.writeTo(bos);
bos.close();
SharedByteArrayInputStream bis =
代码示例来源:origin: camunda/camunda-bpm-platform
super.writeTo(os, ignoreList);
代码示例来源:origin: com.sun.mail/javax.mail
super.writeTo(os, ignoreList);
代码示例来源:origin: org.apache.geronimo.specs/geronimo-javamail_1.4_spec
/**
* Write the message out to a stream in RFC 822 format.
*
* @param out The target output stream.
*
* @exception MessagingException
* @exception IOException
*/
public void writeTo(OutputStream out) throws MessagingException, IOException {
writeTo(out, null);
}
代码示例来源:origin: stackoverflow.com
MimeMessage mimeMessage;
// mimeMessage get assigned
ByteArrayOutputStream output = new ByteArrayOutputStream();
mimeMessage.writeTo(output);
String rawEmail = output.toString();
代码示例来源:origin: org.apache.james/james-server-util
public static String asString(MimeMessage mimeMessage) throws Exception {
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
mimeMessage.writeTo(byteArrayOutputStream);
return new String(byteArrayOutputStream.toByteArray(), StandardCharsets.UTF_8);
}
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) throws Exception {
// manual encoding
System.out.println(MimeUtility.encodeText("How to include £ pound symbol", "UTF-8", "Q"));
System.out.println(MimeUtility.encodeText("How to include £ pound symbol", "UTF-8", "B"));
// MimeMessage encoding
MimeMessage m = new MimeMessage((Session) null);
m.setSubject("How to include £ pound symbol", "UTF-8");
m.setContent("lalala", "text/plain");
m.writeTo(System.out);
}
代码示例来源:origin: stackoverflow.com
MimeMessage msg = new MimeMessage(session);
...
if ("1".equals(System.getProperty("mail.debug"))) {
msg.writeTo(new FileOutputStream(new File("/tmp/sentEmail.eml")));
}
代码示例来源:origin: com.sun.mail/javax.mail
abort.writeTo(new ByteArrayOutputStream(MIN_HEADER_SIZE));
} finally {
getAndSetContextClassLoader(ccl);
代码示例来源:origin: camunda/camunda-bpm-platform
abort.writeTo(new ByteArrayOutputStream(MIN_HEADER_SIZE));
} finally {
getAndSetContextClassLoader(ccl);
代码示例来源:origin: at.researchstudio.sat/won-bot
public void addUriMimeMessageRelation(URI needURI, MimeMessage mimeMessage)
throws IOException, MessagingException {
ByteArrayOutputStream os = new ByteArrayOutputStream();
mimeMessage.writeTo(os);
getBotContext().saveToObjectMap(uriMimeMessageName, needURI.toString(), os.toByteArray());
}
代码示例来源:origin: com.sun.mail/javax.mail
this.message.writeTo(bdat(), ignoreList);
finishBdat();
} else {
this.message.writeTo(data(), ignoreList);
finishData();
代码示例来源:origin: camunda/camunda-bpm-platform
mailFrom();
rcptTo();
this.message.writeTo(data(), ignoreList);
finishData();
if (sendPartiallyFailed) {
内容来源于网络,如有侵权,请联系作者删除!