当前位置: 首页>>代码示例>>Java>>正文


Java Message.saveChanges方法代码示例

本文整理汇总了Java中javax.mail.Message.saveChanges方法的典型用法代码示例。如果您正苦于以下问题:Java Message.saveChanges方法的具体用法?Java Message.saveChanges怎么用?Java Message.saveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.mail.Message的用法示例。


在下文中一共展示了Message.saveChanges方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: sendAttachMail

import javax.mail.Message; //导入方法依赖的package包/类
public boolean sendAttachMail(MailSenderInfo mailInfo) {
    MyAuthenticator authenticator = null;
    Properties pro = mailInfo.getProperties();
    if (mailInfo.isValidate()) {
        authenticator = new MyAuthenticator(mailInfo.getUserName(), mailInfo.getPassword());
    }
    try {
        Message mailMessage = new MimeMessage(Session.getInstance(pro, authenticator));
        mailMessage.setFrom(new InternetAddress(mailInfo.getFromAddress()));
        mailMessage.setRecipient(Message.RecipientType.TO, new InternetAddress(mailInfo.getToAddress()));
        mailMessage.setSubject(mailInfo.getSubject());
        mailMessage.setSentDate(new Date());
        Multipart multi = new MimeMultipart();
        BodyPart textBodyPart = new MimeBodyPart();
        textBodyPart.setContent(mailInfo.getContent(), "text/html; charset=utf-8");
        multi.addBodyPart(textBodyPart);
        for (String path : mailInfo.getAttachFileNames()) {
            DataSource fds = new FileDataSource(path);
            BodyPart fileBodyPart = new MimeBodyPart();
            fileBodyPart.setDataHandler(new DataHandler(fds));
            fileBodyPart.setFileName(path.substring(path.lastIndexOf("/") + 1));
            multi.addBodyPart(fileBodyPart);
        }
        mailMessage.setContent(multi);
        mailMessage.saveChanges();
        Transport.send(mailMessage);
        return true;
    } catch (MessagingException ex) {
        ex.printStackTrace();
        return false;
    }
}
 
开发者ID:JamesLiAndroid,项目名称:AndroidKillerService,代码行数:33,代码来源:SimpleMailSender.java

示例2: send

import javax.mail.Message; //导入方法依赖的package包/类
public void send ( final String subject, final String text ) throws MessagingException
{
    final Message message = new MimeMessage ( this.session );

    if ( this.from != null )
    {
        message.setFrom ( this.from );
    }
    else
    {
        message.setFrom ();
    }

    message.setHeader ( "Return-Path", "<>" );

    message.setRecipients ( javax.mail.Message.RecipientType.TO, this.to );
    message.setSubject ( subject );
    message.setText ( text );

    message.saveChanges ();

    final Transport transport = this.session.getTransport ();
    logger.debug ( "Connecting transport..." );
    transport.connect ();
    logger.debug ( "Connecting transport... done!" );
    try
    {
        logger.debug ( "Sending message..." );
        transport.sendMessage ( message, message.getAllRecipients () );
        logger.debug ( "Sending message... done!" );
    }
    finally
    {
        logger.debug ( "Closing transport..." );
        try
        {
            transport.close ();
            logger.debug ( "Closing transport... done!" );
        }
        catch ( final Exception e )
        {
            logger.info ( "Failed to close transport", e );
        }
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:46,代码来源:MailSender.java

示例3: sendMail

import javax.mail.Message; //导入方法依赖的package包/类
public boolean sendMail(String to,String otp) throws MessagingException 
{
	String host="smtp.gmail.com";
	String username="";//emailid
	String password="";//emailid password
	String from=" ";// email from which u have to send
	String subject="One Time Password";
	String body="Your One Time passsword is "+otp;
	
	boolean sessionDebug=false;
	
	Properties props=System.getProperties();
	props.put("mail.host",host);
	props.put("mail.transport.protocol","smtp");
	props.put("mail.smtp.starttls.enable","true");
	props.put("mail.smtp.auth", "true");
	props.put("mail.smtp.debug", "true");
	props.put("mail.smtp.socketFactory.port", "465");
	props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
	props.put("mail.smtp.socketFactory.fallback", "false");
	props.put("mail.smtp.host", "smtp.gmail.com");
	props.put("mail.smtp.port", "25"); 
	
	Session mailSession=Session.getDefaultInstance(props,null);
	mailSession.setDebug(sessionDebug);
	
	Message msg=new MimeMessage(mailSession);
	msg.setFrom(new InternetAddress(from));
	InternetAddress [] address={new InternetAddress(to)};
	msg.setRecipients(Message.RecipientType.TO,address);
	msg.setSubject(subject);
	msg.setSentDate(new Date());
	msg.setText(body);

	Transport tr=mailSession.getTransport("smtp");
	tr.connect(host,username,password);
	msg.saveChanges();
	tr.sendMessage(msg,msg.getAllRecipients());
	tr.close();
	//Transport.send(msg);
	return true;
}
 
开发者ID:nishittated,项目名称:OnlineElectionVotingSystem,代码行数:43,代码来源:PasswordMail.java

示例4: sendMail1

import javax.mail.Message; //导入方法依赖的package包/类
public boolean sendMail1(String to,String passwrd, String link) throws MessagingException
{
	String host="smtp.gmail.com";
	String username="	 ";//emailid
	String password="";//emailid password
	String from=" ";// email from which u have to send
	String subject="Website Password";
	String body="Your website password is "+passwrd+"  Please click to reset "+link;
	boolean sessionDebug=false;
	
	Properties props=System.getProperties();
	props.put("mail.host",host);
	props.put("mail.transport.protocol","smtp");
	props.put("mail.smtp.starttls.enable","true");
	props.put("mail.smtp.auth", "true");
	props.put("mail.smtp.debug", "true");
	props.put("mail.smtp.socketFactory.port", "465");
	props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
	props.put("mail.smtp.socketFactory.fallback", "false");
	props.put("mail.smtp.host", "smtp.gmail.com");
	props.put("mail.smtp.port", "25"); 
	
	Session mailSession=Session.getDefaultInstance(props,null);
	mailSession.setDebug(sessionDebug);

	Message msg=new MimeMessage(mailSession);
	msg.setFrom(new InternetAddress(from));
	
	InternetAddress [] address={new InternetAddress(to)};
	msg.setRecipients(Message.RecipientType.TO,address);
	msg.setSubject(subject);
	msg.setSentDate(new Date());
	msg.setText(body);
	
	Transport tr=mailSession.getTransport("smtp");
	tr.connect(host,username,password);
	msg.saveChanges();
	tr.sendMessage(msg,msg.getAllRecipients());
	tr.close();
			//Transport.send(msg);
	return true;
}
 
开发者ID:nishittated,项目名称:OnlineElectionVotingSystem,代码行数:43,代码来源:PasswordMail.java

示例5: sendMail2

import javax.mail.Message; //导入方法依赖的package包/类
public boolean sendMail2(String to, String link) throws AddressException, MessagingException {

		String host="smtp.gmail.com";
		String username="	 ";//emailid
		String password="";//emailid password
		String from=" ";// email from which u have to send
		String subject="Website Password";
		String body="Activation Link"+link+"Please click to reset "+link;
		boolean sessionDebug=false;
		
		Properties props=System.getProperties();
		props.put("mail.host",host);
		props.put("mail.transport.protocol","smtp");
		props.put("mail.smtp.starttls.enable","true");
		props.put("mail.smtp.auth", "true");
		props.put("mail.smtp.debug", "true");
		props.put("mail.smtp.socketFactory.port", "465");
		props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
		props.put("mail.smtp.socketFactory.fallback", "false");
		props.put("mail.smtp.host", "smtp.gmail.com");
		props.put("mail.smtp.port", "25"); 
		
		Session mailSession=Session.getDefaultInstance(props,null);
		mailSession.setDebug(sessionDebug);
	
		Message msg=new MimeMessage(mailSession);
		msg.setFrom(new InternetAddress(from));
	
		InternetAddress [] address={new InternetAddress(to)};
		msg.setRecipients(Message.RecipientType.TO,address);
		msg.setSubject(subject);
		msg.setSentDate(new Date());
		msg.setText(body);
	
		Transport tr=mailSession.getTransport("smtp");
		tr.connect(host,username,password);
		msg.saveChanges();
		tr.sendMessage(msg,msg.getAllRecipients());
		tr.close();
			//Transport.send(msg);
		return true;
	}
 
开发者ID:nishittated,项目名称:OnlineElectionVotingSystem,代码行数:43,代码来源:PasswordMail.java


注:本文中的javax.mail.Message.saveChanges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。