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


Java Address.toString方法代碼示例

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


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

示例1: listFolder

import javax.mail.Address; //導入方法依賴的package包/類
static void listFolder(Folder folder, String tab, boolean recurse)
throws Exception {
    folder.open(Folder.READ_WRITE);
    System.out.println(tab + "Name: " + folder.getName() + '(' +
        folder.getFullName() + ')');
    if (!folder.isSubscribed())
        System.out.println(tab + "Not Subscribed");
    if ((folder.getType() & Folder.HOLDS_MESSAGES) != 0) {
        if (folder.hasNewMessages())
            System.out.println(tab + "Has New Messages");
        else
            System.out.println(tab + "No New Messages");
        Message[] msgs = folder.getMessages();
        for (Message m : msgs) {
            Address from = m.getFrom()[0];
            String fromAddress;
            if (from instanceof InternetAddress)
                fromAddress = ((InternetAddress)from).getAddress();
            else
                fromAddress = from.toString();
            StringBuffer sb = new StringBuffer();
            fromFmt.format(fromAddress, sb, null);
            sb.    append("  ");
            subjFmt.format(m.getSubject(), sb, null);
            System.out.println(sb.toString());
        }
    }
    if ((folder.getType() & Folder.HOLDS_FOLDERS) != 0) {
        System.out.println(tab + "Is Directory");
    }
    if (recurse) {
        Folder[] fs = folder.list();
        for (Folder f : fs) {
            listFolder(f, tab + "", recurse);
        }
    }
}
 
開發者ID:shashanksingh28,項目名稱:code-similarity,代碼行數:38,代碼來源:MailLister.java

示例2: toString

import javax.mail.Address; //導入方法依賴的package包/類
public String toString() {
    try {
        Address from = m.getFrom()[0];

        String fromAddress;
        if (from instanceof InternetAddress)
            fromAddress = ((InternetAddress)from).getAddress();
        else
            fromAddress = from.toString();

        StringBuffer sb = new StringBuffer();
        fromFmt.format(fromAddress, sb, null);
        sb.    append("  ");
        subjFmt.format(m.getSubject(), sb, null);
        return sb.toString();
    } catch (Exception e) {
        return e.toString();
    }
}
 
開發者ID:shashanksingh28,項目名稱:code-similarity,代碼行數:20,代碼來源:MessageNode.java

示例3: getSenderEmail

import javax.mail.Address; //導入方法依賴的package包/類
/**
 * Returns the sender email from the provided mail object. 
 * 
 * @param   mailMessage
 *          The mail message with the fax data
 * @return  The sender email
 * @throws  MessagingException
 *          Any exception while handling the mail message
 */
protected String getSenderEmail(Message mailMessage) throws MessagingException
{
    Address[] addresses=mailMessage.getFrom();
    String senderEmail=null;
    if((addresses!=null)&&(addresses.length>0))
    {
        //get sender mail address (only first from is used)
        Address address=addresses[0];
        
        //get as string
        senderEmail=address.toString();
    }

    return senderEmail;
}
 
開發者ID:sagiegurari,項目名稱:fax4j,代碼行數:25,代碼來源:DefaultMailMessageParser.java

示例4: processRecipients

import javax.mail.Address; //導入方法依賴的package包/類
protected void processRecipients(Message message) throws Exception {
  for (Address recipientAddress: message.getAllRecipients()) {
    String recipient = recipientAddress.toString();
    int ltIndex = recipient.indexOf('<');
    int atIndex = recipient.indexOf('@');
    int gtIndex = recipient.indexOf('>');
    if ( (ltIndex!=-1)
         && (atIndex!=-1)
         && (gtIndex!=-1)
         && (ltIndex<atIndex)
         && (atIndex<gtIndex) ) {
      recipient = recipient.substring(ltIndex+1, gtIndex);
    }
    recipients.add(recipient);
  }
}
 
開發者ID:logicalhacking,項目名稱:SecureBPMN,代碼行數:17,代碼來源:MailTransformer.java

示例5: getAddressAsString

import javax.mail.Address; //導入方法依賴的package包/類
private static String getAddressAsString(Address[] addresses) {
    StringBuffer addresssb = new StringBuffer();
    for (Address address : addresses){
        String addressstr = address.toString();
        int startIndex = addressstr.indexOf("<");
        int endIndex = addressstr.indexOf(">");
        if (startIndex != -1 || endIndex != -1) {
            addressstr = addressstr.substring(startIndex+1, endIndex);
        }
        addresssb.append(addressstr);
        addresssb.append(";");
    }
    return addresssb.toString();
}
 
開發者ID:CenturyLinkCloud,項目名稱:mdw,代碼行數:15,代碼來源:MDWEmailListener.java

示例6: toEmail

import javax.mail.Address; //導入方法依賴的package包/類
/**
 * @param address The address, hopefully an {@link InternetAddress}
 * @return The email address if it can, otherwise the whole address.
 */
private String toEmail(Address address)
{
	if (address instanceof InternetAddress)
	{
		return ((InternetAddress) address).getAddress();
	}
	else
	{
		return address.toString();
	}
}
 
開發者ID:sakaiproject,項目名稱:sakai,代碼行數:16,代碼來源:BasicEmailService.java


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