Coder Social home page Coder Social logo

Comments (7)

ibalosh avatar ibalosh commented on July 29, 2024 1

Hi,

thank you for contacting us back regarding the library. The main reason behind that is avoiding mistakes when doing attachments creation on the fly. Its much easier to make sure attachment is correct by having it in the file, and allowing the library to read, encode and send it for you.

We can add overload method for adding attachments on fly too. Could you share example on how you plan to add attachments on the fly, so we have better idea on whether its a good fit to add to the model?

from postmark-java.

jflebeau avatar jflebeau commented on July 29, 2024 1

Scenario : provide a "copy" of the content of the email as a CSV file attachment. In that case it doesn't make sense for me to create a temporary file that would then be read by Postmark API.

Maybe an InputStream? (i.e. ByteArrayInputStream), that could be useful for files too...

from postmark-java.

ibalosh avatar ibalosh commented on July 29, 2024 1

Hey @jflebeau

Got it, I will be doing some updates to library this week. Will tackle adding attachments on the fly too.

from postmark-java.

ibalosh avatar ibalosh commented on July 29, 2024 1

oops, you are right, added it for regular messages only. Updated TemplatedMessage model too, should be up in less than an hour.

from postmark-java.

ibalosh avatar ibalosh commented on July 29, 2024

Hi @jflebeau

I was checking out today the model for messages and you can actually attach attachments on fly.
There is support for it.

Check out the following example:

Message message = new Message("[email protected]", "[email protected]", "Subject", "Body");

String test = "test message line 1\ntest message line 2";
        
HashMap<String,String> attachment = new HashMap<>();
attachment.put("Name", "filename.txt");
attachment.put("Content", Base64.getEncoder().encodeToString(test.getBytes()));
attachment.put("ContentType", "text");
message.addAttachment(attachment);

I will add though additional helpers and update documentation to make it clearer. Many thanks on catching that and using the library!
and then send the message.

from postmark-java.

ibalosh avatar ibalosh commented on July 29, 2024

Hi @jflebeau

the library has been updated. You should be able to easily attach content on the fly with couple of new options. Check out the wiki for details:

https://github.com/wildbit/postmark-java/wiki/Email-sending

from postmark-java.

jflebeau avatar jflebeau commented on July 29, 2024

This method doesn't exist for TemplateMessage.

from postmark-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.