Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Sicos2002 committed Jan 23, 2017
2 parents c6e232e + 21b28aa commit a77e425
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
17 changes: 12 additions & 5 deletions MsgKit/Attachments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ public class Attachments : List<Attachment>
/// Checks if the <paramref name="fileName" /> already exists in this object
/// </summary>
/// <param name="fileName"></param>
private void CheckAttachmentFileName(string fileName)
/// <param name="contentId"></param>
private void CheckAttachmentFileName(string fileName, string contentId)
{
var file = Path.GetFileName(fileName);

if (this.Any(
attachment => attachment.FileName.Equals(fileName, StringComparison.InvariantCultureIgnoreCase)))
attachment => attachment.FileName.Equals(fileName, StringComparison.InvariantCultureIgnoreCase)
&& string.Equals(attachment.ContentId, contentId, StringComparison.InvariantCultureIgnoreCase)))
throw new MKAttachmentExists("The attachment with the name '" + file + "' already exists");
}
#endregion
Expand Down Expand Up @@ -103,7 +105,7 @@ public void Add(string fileName,
bool isInline = false,
string contentId = "")
{
CheckAttachmentFileName(fileName);
CheckAttachmentFileName(fileName, contentId);
var file = new FileInfo(fileName);

Add(new Attachment(file,
Expand Down Expand Up @@ -136,7 +138,7 @@ public void Add(System.IO.Stream stream,
if (stream == null)
throw new ArgumentNullException("stream");

CheckAttachmentFileName(fileName);
CheckAttachmentFileName(fileName, contentId);
var dateTime = DateTime.Now;

Add(new Attachment(stream,
Expand Down Expand Up @@ -173,7 +175,7 @@ public void AddLink(string fileName,
bool isInline = false,
string contentId = "")
{
CheckAttachmentFileName(fileName);
CheckAttachmentFileName(fileName, contentId);
var file = new FileInfo(fileName);

Add(new Attachment(file,
Expand Down Expand Up @@ -371,6 +373,11 @@ internal long WriteProperties(CFStorage storage, int index)
propertiesStream.AddProperty(PropertyTags.PR_ATTACH_FILENAME_W, GetShortFileName(FileName));
propertiesStream.AddProperty(PropertyTags.PR_ATTACH_LONG_FILENAME_W, FileName);
propertiesStream.AddProperty(PropertyTags.PR_ATTACH_EXTENSION_W, Path.GetExtension(FileName));

if (!string.IsNullOrEmpty(this.ContentId))
{
propertiesStream.AddProperty(PropertyTags.PR_ATTACH_CONTENT_ID_W, this.ContentId);
}
}

propertiesStream.AddProperty(PropertyTags.PR_ATTACH_METHOD, Type);
Expand Down
2 changes: 1 addition & 1 deletion MsgKit/Helpers/Mapi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public static byte[] GenerateInstanceKey()
/// <returns></returns>
public static byte[] GenerateEntryId()
{
return Guid.NewGuid().ToByteArray();
return Encoding.Unicode.GetBytes(Guid.NewGuid().ToString());
}
#endregion
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ MsgKit is a 100% managed C# .NET library (no PINVOKE or whatsoever) which may be

## License Information

MimeKit is Copyright (C) 2015-2016 Magic-Sessions and is licensed under the MIT license:
MsgKit is Copyright (C) 2015-2017 Magic-Sessions and is licensed under the MIT license:

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down

0 comments on commit a77e425

Please sign in to comment.