/** * Attach a file referenced by the given link. * * <p> * If you want to reference the attachment as inline image, provide content * id wrapped by angle brackets and refer the image with content id without * angle brackets. * </p> * * For example: * * <pre> * builder * .html("<img src='cid:logo.png'>") * .attach("logo.png", "/path/to/logo.png", "<logo.png>" * .send(); * <pre> * * @param name * attachment file name * @param link * attachment file link (url or file path) * @param cid * content id * @return this */ public MailBuilder attach(String name, String link, String cid) { Preconditions.checkNotNull(link, "link can't be null"); Content content = new Content(); content.name = name; content.file = link; content.cid = cid; contents.add(content); textOnly = false; return this; }
/** * Attach a file as inline content. * * @param name attachment file name * @param link attachment file link (url or file path) * @param inline whether to inline this attachment * @return this */ public MailBuilder inline(String name, String link) { Preconditions.checkNotNull(link, "link can't be null"); Content content = new Content(); content.name = name; content.file = link; content.cid = "<" + name + ">"; content.inline = true; contents.add(content); textOnly = false; return this; }