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


Java Email类代码示例

本文整理汇总了Java中com.mailjet.client.resource.Email的典型用法代码示例。如果您正苦于以下问题:Java Email类的具体用法?Java Email怎么用?Java Email使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: parseToEmail

import com.mailjet.client.resource.Email; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public MailjetRequest parseToEmail(EmailWrapper wrapper) {
    MailjetRequest request = new MailjetRequest(Email.resource);
    request.property(Email.FROMEMAIL, wrapper.getSenderEmail());
    if (wrapper.getSenderName() != null && !wrapper.getSenderName().isEmpty()) {
        request.property(Email.FROMNAME, wrapper.getSenderName());
    }

    request.property(Email.RECIPIENTS, new JSONArray().put(new JSONObject().put("Email", wrapper.getRecipient())));
    if (wrapper.getBcc() != null && !wrapper.getBcc().isEmpty()) {
        request.append(Email.RECIPIENTS, new JSONObject().put("Email", wrapper.getBcc()));
    }

    request.property(Email.HEADERS, new JSONObject().put("Reply-To", wrapper.getReplyTo()));
    request.property(Email.SUBJECT, wrapper.getSubject());
    request.property(Email.HTMLPART, wrapper.getContent());
    request.property(Email.TEXTPART, Jsoup.parse(wrapper.getContent()).text());
    return request;
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:23,代码来源:MailjetService.java

示例2: testConvertToMailjet

import com.mailjet.client.resource.Email; //导入依赖的package包/类
@Test
public void testConvertToMailjet() {
    EmailWrapper wrapper = getTypicalEmailWrapper();
    MailjetRequest request = new MailjetService().parseToEmail(wrapper);
    JSONObject email = new JSONObject(request.getBody());

    assertEquals(wrapper.getSenderEmail(), email.get(Email.FROMEMAIL));
    assertEquals(wrapper.getSenderName(), email.get(Email.FROMNAME));
    assertEquals(wrapper.getRecipient(),
                 ((JSONArray) email.get(Email.RECIPIENTS)).getJSONObject(0).get("Email"));
    assertEquals(wrapper.getBcc(),
                 ((JSONArray) email.get(Email.RECIPIENTS)).getJSONObject(1).get("Email"));
    assertEquals(wrapper.getReplyTo(),
                 ((JSONObject) email.get(Email.HEADERS)).getString("Reply-To"));
    assertEquals(wrapper.getSubject(), email.get(Email.SUBJECT));
    assertEquals(wrapper.getContent(), email.get(Email.HTMLPART));
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:18,代码来源:EmailSenderTest.java

示例3: testConvertToSendgrid

import com.mailjet.client.resource.Email; //导入依赖的package包/类
@Test
public void testConvertToSendgrid() {
    EmailWrapper wrapper = getTypicalEmailWrapper();
    SendGrid.Email email = new SendgridService().parseToEmail(wrapper);

    assertEquals(wrapper.getSenderEmail(), email.getFrom());
    assertEquals(wrapper.getSenderName(), email.getFromName());
    assertEquals(wrapper.getRecipient(), email.getTos()[0]);
    assertEquals(wrapper.getBcc(), email.getBccs()[0]);
    assertEquals(wrapper.getReplyTo(), email.getReplyTo());
    assertEquals(wrapper.getSubject(), email.getSubject());
    assertEquals(wrapper.getContent(), email.getHtml());
}
 
开发者ID:TEAMMATES,项目名称:teammates,代码行数:14,代码来源:EmailSenderTest.java

示例4: from

import com.mailjet.client.resource.Email; //导入依赖的package包/类
/**
 * Set the sender
 * @param email Email address of the sender
 * @param name Name of the sender
 * @return Current instance
 */
public MJEasyEmail from(String email, String name) {
    request.property(Email.FROMEMAIL, email);
    if (name != null) {
        request.property(Email.FROMNAME, name);
    }
    return this;
}
 
开发者ID:mailjet,项目名称:mailjet-apiv3-java,代码行数:14,代码来源:MJEasyEmail.java

示例5: testSendv3

import com.mailjet.client.resource.Email; //导入依赖的package包/类
@Test
public void testSendv3() throws MailjetException, MalformedURLException, UnsupportedEncodingException, MailjetSocketTimeoutException {
    MailjetClient client;

    client = new MailjetClient("", "");
    client.setDebug(MailjetClient.NOCALL_DEBUG);

    System.out.println("TESTING: Send email with Send API v3.0");

    MailjetRequest request;
    MailjetResponse response;

    String fromEmail =  "[email protected]",
           fromName = "Mailjet Pilot",
           subject = "Your email flight plan!",
           textPart = "Dear passenger, welcome to Mailjet! May the delivery force be with you!",
           htmlPart = "<h3>Dear passenger, welcome to Mailjet</h3><br/>May the delivery force be with you!",
           recipient = "[email protected]";

    // Simple contact GET request
    request = new MailjetRequest(Email.resource)
                    .property(Email.FROMEMAIL, fromEmail)
                    .property(Email.FROMNAME, fromName)
                    .property(Email.SUBJECT, subject)
                    .property(Email.TEXTPART, textPart)
                    .property(Email.HTMLPART, htmlPart)
                    .property(Email.RECIPIENTS, new JSONArray()
                    .put(new JSONObject()
                    .put(Email.EMAIL, recipient)));
    response = client.post(request);
    assertEquals(response.getString("url"), "https://api.mailjet.com/v3/send");
}
 
开发者ID:mailjet,项目名称:mailjet-apiv3-java,代码行数:33,代码来源:MailjetClientTest.java

示例6: to

import com.mailjet.client.resource.Email; //导入依赖的package包/类
/**
 * Add a recipient
 * @param email Email of the recipient
 * @return Current instance
 */
public MJEasyEmail to(String email) {
    recipients.put(new JSONObject().put(Contact.EMAIL, email));
    request.property(Email.RECIPIENTS, recipients);
    return this;
}
 
开发者ID:mailjet,项目名称:mailjet-apiv3-java,代码行数:11,代码来源:MJEasyEmail.java

示例7: email

import com.mailjet.client.resource.Email; //导入依赖的package包/类
/**
 * Create an MJEasyEmail instance to prepare an email to send.
 * @return MJEasyEMail instance
 */
public MJEasyEmail email() {
    return new MJEasyEmail(this, new MailjetRequest(Email.resource));
}
 
开发者ID:mailjet,项目名称:mailjet-apiv3-java,代码行数:8,代码来源:MJEasyClient.java


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