當前位置: 首頁>>代碼示例>>Java>>正文


Java NoSuchProviderException類代碼示例

本文整理匯總了Java中javax.mail.NoSuchProviderException的典型用法代碼示例。如果您正苦於以下問題:Java NoSuchProviderException類的具體用法?Java NoSuchProviderException怎麽用?Java NoSuchProviderException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


NoSuchProviderException類屬於javax.mail包,在下文中一共展示了NoSuchProviderException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sendMessage

import javax.mail.NoSuchProviderException; //導入依賴的package包/類
public void sendMessage (Message oMsg,
                         Address[] aAdrFrom, Address[] aAdrReply,
                         Address[] aAdrTo, Address[] aAdrCc, Address[] aAdrBcc)
  throws NoSuchProviderException,SendFailedException,ParseException,
         MessagingException,NullPointerException {           	
  oMsg.addFrom(aAdrFrom);
  if (null==aAdrReply)
    oMsg.setReplyTo(aAdrReply);
  else
    oMsg.setReplyTo(aAdrFrom);
  if (aAdrTo!=null) oMsg.addRecipients(javax.mail.Message.RecipientType.TO, aAdrTo);
  if (aAdrCc!=null) oMsg.addRecipients(javax.mail.Message.RecipientType.CC, aAdrCc);
  if (aAdrBcc!=null) oMsg.addRecipients(javax.mail.Message.RecipientType.BCC, aAdrBcc);
  oMsg.setSentDate(new java.util.Date());
  Transport.send(oMsg);
}
 
開發者ID:sergiomt,項目名稱:zesped,代碼行數:17,代碼來源:MailSessionHandler.java

示例2: markMessagesAsRead

import javax.mail.NoSuchProviderException; //導入依賴的package包/類
public void markMessagesAsRead(String[] ids, boolean seen) throws NoSuchProviderException, MessagingException, IOException {
  IMAPFolder folder = (IMAPFolder)getStore().getFolder("Inbox");
  folder.open(Folder.READ_WRITE);
  UIDFolder uidFolder = folder;
  
  Message[] msgs;
  

  long[] uids = new long[ids.length];
  int i = 0;
  for (String s : ids) {
    try {
      uids[i++] = Long.parseLong(s);
    } catch (Exception ex) {
      Log.d("rgai", "", ex);
    }
  }
  // TODO: if instance not support UID, then use simple id
  msgs = uidFolder.getMessagesByUID(uids);

  folder.setFlags(msgs, new Flags(Flags.Flag.SEEN), seen);

  folder.close(false);
}
 
開發者ID:k-kojak,項目名稱:yako,代碼行數:25,代碼來源:SimpleEmailMessageProvider.java

示例3: run

import javax.mail.NoSuchProviderException; //導入依賴的package包/類
@Override
public void run() {
    //we only need to send the message so we use smtps
    try (Transport transport = session.getTransport()) {
        EmailConfiguration emailConfig = plugin.getConfigManager().getGeneral().getEmail();

        //connect to host and send message
        if (!transport.isConnected()) {
            String password = emailConfig.getPassword();
            transport.connect(emailConfig.getHost(), emailConfig.getAccount(), password);
        }

        transport.sendMessage(email, email.getAllRecipients());
        player.sendMessage(plugin.getConfigManager().getText().getMailSent());
    } catch (NoSuchProviderException providerEx) {
        plugin.getLogger().error("Transport provider not found", providerEx);
        plugin.getLogger().error("Registered providers: {}", Arrays.asList(session.getProviders()));

        player.sendMessage(plugin.getConfigManager().getText().getErrorCommand());
    } catch (MessagingException messagingEx) {
        plugin.getLogger().error("Error sending email", messagingEx);
        player.sendMessage(plugin.getConfigManager().getText().getErrorCommand());
    }
}
 
開發者ID:games647,項目名稱:FlexibleLogin,代碼行數:25,代碼來源:SendMailTask.java

示例4: init

import javax.mail.NoSuchProviderException; //導入依賴的package包/類
@PostConstruct
public void init() {
	if (session == null) {
		throw new IllegalStateException("JavaMail session is null.");
	}
	javaMailSessionDelegate = new JavaMailSessionDelegate() {
		@Override
		public Transport findTransport(String protocolToUse) throws NoSuchProviderException {
			return session.getTransport(protocolToUse);
		}
		@Override
		public MimeMessage createMimeMessage(InputStream inputStream) throws MessagingException {
			return new MimeMessage(session, inputStream);
		}
	};
}
 
開發者ID:m-szalik,項目名稱:javamail,代碼行數:17,代碼來源:JMS2JavaMail.java

示例5: EmailDownloaderDialog

import javax.mail.NoSuchProviderException; //導入依賴的package包/類
public EmailDownloaderDialog(java.awt.Frame parent, boolean modal,
        final Case aCase, final EmailConfiguration emailConfiguration) throws SQLException, NoSuchProviderException, MessagingException, IOException, Exception {
    super(parent, modal);
    
    initComponents();
    setLocationRelativeTo(parent);        
    
    this.DownloadProgressBar.setIndeterminate(true);
    this.aCase = aCase;
    this.emailConfiguration = emailConfiguration;
    
    this.onlineEmailDownloader = new OnlineEmailDownloader(this,
        this.aCase.getCaseLocation() + "\\" + ApplicationConstants.CASE_ONLINE_EMAIL_ATTACHMENTS_FOLDER,
        this.aCase.getCaseLocation() + "\\" + ApplicationConstants.CASE_EMAIL_DB_FOLDER,
        this.aCase.getCaseLocation() + "\\" + ApplicationConstants.CASE_ARCHIVE_FOLDER
        );
}
 
開發者ID:CoEIA,項目名稱:DEM,代碼行數:18,代碼來源:EmailDownloaderDialog.java

示例6: testJavaMailProperties

import javax.mail.NoSuchProviderException; //導入依賴的package包/類
public void testJavaMailProperties() throws MessagingException {
	Properties props = new Properties();
	props.setProperty("bogusKey", "bogusValue");
	MockJavaMailSender sender = new MockJavaMailSender() {
		@Override
		protected Transport getTransport(Session sess) throws NoSuchProviderException {
			assertEquals("bogusValue", sess.getProperty("bogusKey"));
			return super.getTransport(sess);
		}
	};
	sender.setJavaMailProperties(props);
	sender.setHost("host");
	sender.setUsername("username");
	sender.setPassword("password");

	MimeMessage mimeMessage = sender.createMimeMessage();
	mimeMessage.setRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]"));
	sender.send(mimeMessage);

	assertEquals("host", sender.transport.getConnectedHost());
	assertEquals("username", sender.transport.getConnectedUsername());
	assertEquals("password", sender.transport.getConnectedPassword());
	assertTrue(sender.transport.isCloseCalled());
	assertEquals(1, sender.transport.getSentMessages().size());
	assertEquals(mimeMessage, sender.transport.getSentMessage(0));
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:27,代碼來源:JavaMailSenderTests.java

示例7: retrieveMail

import javax.mail.NoSuchProviderException; //導入依賴的package包/類
private void retrieveMail() throws NoSuchProviderException,
        MessagingException, IOException {
    Properties properties = new Properties();
    Session session = Session.getInstance(properties);
    Store store =
            session.getStore(new URLName("pop3://john:[email protected]:"
                    + PORT_POP + "/INBOX"));
    store.connect();
    Folder folder = store.getFolder("INBOX");
    folder.open(Folder.READ_WRITE);
    Message[] messages = folder.getMessages();
    assertEquals(1, messages.length);
    Message message = messages[0];
    assertEquals("Hello World!\r\n", message.getContent());
    message.setFlag(Flags.Flag.DELETED, true);
    folder.close(true);
    store.close();
}
 
開發者ID:hontvari,項目名稱:mireka,代碼行數:19,代碼來源:MxPopTest.java

示例8: getStore

import javax.mail.NoSuchProviderException; //導入依賴的package包/類
/**
 * Connects to imap, returns a store.
 * 
 * @return the store where, where you can read the emails
 * @throws NoSuchProviderException
 * @throws MessagingException
 * @throws AuthenticationFailedException 
 */
private synchronized Store getStore() throws NoSuchProviderException, MessagingException, AuthenticationFailedException {
  Properties props = System.getProperties();
  this.setProperties(props);
  Session session = Session.getDefaultInstance(props, null);
  Store store;
  if (this.account.isSsl()) {
    store = session.getStore("imaps");
  } else {
    store = session.getStore("imap");
  }
  Log.d("rgai3", "connecting with account: " + account);
  store.connect(account.getImapAddress(), account.getEmail(), account.getPassword());
  
  return store;
}
 
開發者ID:k-kojak,項目名稱:yako,代碼行數:24,代碼來源:SimpleEmailMessageProvider.java

示例9: markMessageAsRead

import javax.mail.NoSuchProviderException; //導入依賴的package包/類
@Override
public void markMessageAsRead(String id, boolean seen) throws NoSuchProviderException, MessagingException, IOException {
  
  IMAPFolder folder = (IMAPFolder)getStore().getFolder("Inbox");
  folder.open(Folder.READ_WRITE);
  UIDFolder uidFolder = (UIDFolder)folder;
  
  Message ms = uidFolder.getMessageByUID(Long.parseLong(id));

  if (ms != null) {
    ms.setFlag(Flags.Flag.SEEN, seen);
  }
  folder.close(false);
}
 
開發者ID:k-kojak,項目名稱:yako,代碼行數:15,代碼來源:SimpleEmailMessageProvider.java

示例10: deleteMessage

import javax.mail.NoSuchProviderException; //導入依賴的package包/類
public void deleteMessage(String id) throws NoSuchProviderException, MessagingException, IOException {
  IMAPFolder folder = (IMAPFolder)getStore().getFolder("Inbox");
  folder.open(Folder.READ_WRITE);
  UIDFolder uidFolder = (UIDFolder)folder;
  
  Message ms = uidFolder.getMessageByUID(Long.parseLong(id));

  if (ms != null) {
    ms.setFlag(Flags.Flag.DELETED, true);
  }
  folder.close(true);
}
 
開發者ID:k-kojak,項目名稱:yako,代碼行數:13,代碼來源:SimpleEmailMessageProvider.java

示例11: sendMessage

import javax.mail.NoSuchProviderException; //導入依賴的package包/類
private void sendMessage() throws NoSuchProviderException, MessagingException, IOException {
    props = PropertiesReader.getProps();

    props.list(System.out);
    System.out.println("\n========message follows==========\n");
    session = Session.getInstance(props);
    session.setDebug(true);
    message = new MimeMessage(session);
    String host = props.getProperty("mail.smtp.host");
    String user = props.getProperty("mail.smtp.user");
    String password = props.getProperty("mail.smtp.password");
    int port = Integer.parseInt(props.getProperty("mail.smtp.port"));
    System.out.println(host + user + password + port);
    message.setFrom(new InternetAddress(props.getProperty("mail.smtp.user")));
    message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(props.getProperty("mail.smtp.user"), false));
    message.setText("hello gmail");
    System.out.println(message.getFrom().toString());
    System.out.println(message.getRecipients(Message.RecipientType.TO).toString());
    System.out.println(message.getContent().toString());
    transport = (SMTPTransport) session.getTransport("smtp");
    System.out.println("trying...");
    transport.connect(host, port, user, password);
    System.out.println("...connected");
    transport.sendMessage(message, message.getAllRecipients());
    transport.close();
}
 
開發者ID:THUFIR,項目名稱:MailFromNNTP,代碼行數:27,代碼來源:Gmail.java

示例12: sendMessage

import javax.mail.NoSuchProviderException; //導入依賴的package包/類
private void sendMessage() throws NoSuchProviderException, MessagingException, IOException {
    final Properties props = PropertiesReader.getProps();
    props.list(System.out);
    System.out.println("\n========message follows==========\n");
    Session session = Session.getInstance(props,
            new javax.mail.Authenticator() {

                @Override
                protected PasswordAuthentication getPasswordAuthentication() {
                    return new PasswordAuthentication(props.getProperty("mail.smtp.username"), props.getProperty("mail.smtp.password"));
                }
            });
    try {
        Message message = new MimeMessage(session);
        message.setFrom(new InternetAddress(props.getProperty("mail.smtp.username")));
        message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(props.getProperty("mail.smtp.username")));
        message.setSubject("Testing Subject");
        message.setText("Dear Google,\n\n please accept this authenticator.");
        Transport.send(message);
        System.out.println("Done");

    } catch (MessagingException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:THUFIR,項目名稱:MailFromNNTP,代碼行數:26,代碼來源:SendTLS.java

示例13: main

import javax.mail.NoSuchProviderException; //導入依賴的package包/類
public static void main(String[] args) throws IOException, NoSuchProviderException, MessagingException {

        Properties properties = new Properties();
        properties.load(new InputStreamReader(
                    ClassLoader.class.getResourceAsStream("/account.properties"), "UTF-8"));

        final String HOST = properties.getProperty("HOST");
        final String PORT = properties.getProperty("PORT");
        final String USER = properties.getProperty("USER");
        final String PASSWORD = properties.getProperty("PASSWORD");

        System.out.println(properties);

        Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

        Properties gmailProperties = new Properties();
        gmailProperties.put("mail.imap.starttls.enable","true");
        gmailProperties.put("mail.imap.auth", "true");
        gmailProperties.put("mail.imap.socketFactory.port", PORT);
        gmailProperties.put("mail.imap.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
        gmailProperties.put("mail.imap.socketFactory.fallback", "false");

        Session session = Session.getDefaultInstance(gmailProperties, null);
        Store store = session.getStore("imap");
        store.connect(HOST, USER, PASSWORD);

        Folder folder = store.getFolder(properties.getProperty("LABEL"));
        folder.open(Folder.READ_ONLY);

        for (Message message : folder.getMessages()) {
            System.out.printf("Subject: %s\n", message.getSubject());
            System.out.printf("Received Date: %s\n", message.getReceivedDate());

            System.out.printf("Content:\n%s\n", getText(message.getContent()));
        }

        folder.close(false);
    }
 
開發者ID:mikoto2000,項目名稱:MiscellaneousStudy,代碼行數:39,代碼來源:GetMail.java

示例14: senderConnect

import javax.mail.NoSuchProviderException; //導入依賴的package包/類
public void senderConnect() throws NoSuchProviderException, MessagingException {
    senderSession = Session.getInstance(pManager.getSenderProps());
    //senderSession.setDebugOut(pManager.get_Log_Stream());
    
    transport = (SMTPTransport)(senderSession.getTransport("smtp"));
    transport.connect(pManager.get_SENDER_User(), pManager.get_SENDER_Pass());
}
 
開發者ID:adbenitez,項目名稱:MailCopier,代碼行數:8,代碼來源:MailCopier.java

示例15: receiverConnect

import javax.mail.NoSuchProviderException; //導入依賴的package包/類
public void receiverConnect() throws NoSuchProviderException, MessagingException {
    receiverSession = Session.getInstance(pManager.getReceiverProps());
    //receiverSession.setDebugOut(pManager.get_Log_Stream());
    
    store = receiverSession.getStore(pManager.get_RECEIVER_Protocol());
    store.connect(pManager.get_RECEIVER_User(), pManager.get_RECEIVER_Pass());
}
 
開發者ID:adbenitez,項目名稱:MailCopier,代碼行數:8,代碼來源:MailCopier.java


注:本文中的javax.mail.NoSuchProviderException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。