This project is read-only.

How to add attachments and pass custom content item to Message Handler (Email)

Topics: Writing modules
Jul 9, 2012 at 4:35 PM

Hi, I am writing a module where I need to attach files uploaded by the user in the email. Also My content part contains non string fields like date and numeric which I don't want to send as string. How can I pass these two things(file and my content part) to Message Handler so that I can attach those to message. Or is there any way to do this. Sorry if my question is vague.





Jul 9, 2012 at 10:40 PM

I got around this by just creating a class to hold all this contextual data.  Something like this...

public interface ICustomEmailContext : IDependency {
   byte[] SomeImage {get;set;}
   DateTime SomeDate {get;set;}

public class MyCustomEmailContext : ICustomEmailContext {
   public byte[] SomeImage {get;set;}
   public DateTime SomeDate {get;set;}

Then just inject it into the constructors of your message handler and wherever you are populating it from.  They are the same instance so the data is accessible in both places.