Giter Site home page Giter Site logo

s22.mail's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

s22.mail's Issues

S22.Mail.dll not found ?

Hi,
Where can i download S22.Mail.dll file. I need to store Message attachment into local hard drive.. Is there any work around for achieving this?

Json Serialization

When you try to serialize the object with not with MemoryStream but with Json.NET
"JsonConvert.SerializeObject((SerializableMailMessage)message, Formatting.Indented);"
you receive this error:
Newtonsoft.Json.JsonSerializationException: 'Error getting value from 'ReadTimeout' on 'System.IO.MemoryStream'.'
It's possible to avoid this problem in the library or we need to act on Json.NET library?

Attachment filename not being saved when converting to ToMIME822, here is the fix

In MailMessage.cs when an attachment is saved then subsequently recreated it appears that the original attachment name is lost and a new random string is generated in it's place.

To fix this I changed line 269 as follows:

builder.AppendLine(string.Format("Content-Disposition: attachment; filename="{0}"", ((Attachment)view).Name));

System.FormatException on SmtpDateTime.ParseValue after multiple serialization/deserialization

Step to reproduce:

  • create a MailMessage with an attachment
  • serialize to FileStream using BinaryFormatter
  • deserialize using BinaryFormatter
  • serialize to a new different file
  • deserialize and then you got the exception

Code example:

        public static void Serialize(MailMessage message, string file)
        {
            using (var stream = new FileStream(file, FileMode.Create))
            {
                new BinaryFormatter().Serialize(stream, (SerializableMailMessage)message);
            }
        }

        public static MailMessage Deserialize(string file)
        {
            using (var stream = File.OpenRead(file))
            {
                return (SerializableMailMessage)new BinaryFormatter().Deserialize(stream);
            }
        }

        static void Main(string[] args)
        {
            using (var mail = new MailMessage())
            {
                mail.Attachments.Add(new Attachment(@"c:\temp\attachment.pdf"));
                mail.From = new MailAddress("[email protected]");
                mail.To.Add("[email protected]");
                mail.Subject = "subject";
                mail.Body = "body";

                Serialize(mail, @"c:\temp\mail.bin");
            }

            MailMessage tmp = Deserialize(@"c:\temp\mail.bin");
            Serialize(tmp, @"c:\temp\tmp.bin");
            Deserialize(@"c:\temp\tmp.bin"); // <-- System.FormatException
        }

Exception details:

System.FormatException was unhandled
  HResult=-2146233033
  IsTransient=false
  Message=The date is in an invalid format.
  Source=System
  StackTrace:
       at System.Net.Mime.SmtpDateTime.ParseValue(String data, String& timeZone)
       at System.Net.Mime.SmtpDateTime..ctor(String value)
       at System.Net.Mime.ContentDisposition.<.cctor>b__0(Object value)
       at System.Net.TrackingValidationObjectDictionary.PersistValue(String key, String value, Boolean addValue)
       at System.Net.TrackingValidationObjectDictionary.Add(String key, String value)
       at S22.Mail.SerializableAttachment.op_Implicit(SerializableAttachment attachment)
       at S22.Mail.SerializableMailMessage.op_Implicit(SerializableMailMessage message)
       at ConsoleApplication3.Program.Deserialize(String file) in c:\..\Program.cs:line 34
       at ConsoleApplication3.Program.Main(String[] args) in c:\..\Program.cs:line 53
  InnerException: 

Encoding problem

Hello. When I receive mails using S22, for characters with accent (like á, é, í, ó, ú) I have problems.

For example, instead of "la solución es" I receive "la soluci???n es".

How can I fix that?

Regards!

Incorrect System.Net.Mime.ContentDisposition creation from SerializableContentDisposition

When setting properties (CreationDate, FileName, ModificationDate, ReadDate) of ContentDisposition
is automatically performed the addition of the respective element to the list of parameters.
Subsequently, while copying the parameters you need to check if they are not already present.
Currently this missing check generates an exception during deserialization.

Code example :

public static void Serialize(MailMessage message, string file)
{
    using (var stream = new FileStream(file, FileMode.Create))
    {
        new BinaryFormatter().Serialize(stream, (SerializableMailMessage)message);
    }
}

public static MailMessage Deserialize(string file)
{
    using (var stream = File.OpenRead(file))
    {
        return (SerializableMailMessage)new BinaryFormatter().Deserialize(stream);
    }
}

static void Main(string[] args)
{
    var mail = new MailMessage();

    var attachment = new Attachment(@"c:\foo.pdf");
    attachment.ContentDisposition.CreationDate = DateTime.Now; // <-- set property
    mail.Attachments.Add(attachment);

    mail.From = new MailAddress("[email protected]");
    mail.To.Add("[email protected]");
    mail.Subject = "subject";
    mail.Body = "body";

    Serialize(mail, @"c:\mail.bin");
    var tmp = Deserialize(@"c:\mail.bin"); // <-- System.ArgumentException
}

Exception details :

System.ArgumentException was unhandled
  Message=An item with the same key has already been added.
  Source=mscorlib
  StackTrace:
       at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
       at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
       at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
       at System.Net.TrackingValidationObjectDictionary.PersistValue(String key, String value, Boolean addValue)
       at System.Net.TrackingValidationObjectDictionary.Add(String key, String value)
       at S22.Mail.SerializableAttachment.op_Implicit(SerializableAttachment attachment)
       at S22.Mail.SerializableMailMessage.op_Implicit(SerializableMailMessage message)
       at ConsoleApplication1.Program.Deserialize(String file)
       at ConsoleApplication1.Program.Main(String[] args)
       [...]
  InnerException: 

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.