当前位置: 首页>>代码示例>>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;未经允许,请勿转载。