forked from smsohan/MvcMailer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18a3a6d
commit fc9573a
Showing
16 changed files
with
162 additions
and
354 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,17 @@ | ||
using System.Web.Mvc; | ||
using System; | ||
using System.Web; | ||
using System.Text; | ||
|
||
namespace Mvc.Mailer | ||
{ | ||
public static class HtmlHelperExtensions | ||
{ | ||
namespace Mvc.Mailer { | ||
public static class HtmlHelperExtensions { | ||
/// <summary> | ||
/// Produces the tag for inline image | ||
/// </summary> | ||
/// <param name="htmlHelper"></param> | ||
/// <param name="contentId">e.g. logo</param> | ||
/// <param name="alt">e.g. Company Logo</param> | ||
/// <returns><img src="cid:logo" alt="Company Logo"/></returns> | ||
public static IHtmlString InlineImage(this HtmlHelper htmlHelper, string contentId, string alt = "") | ||
{ | ||
public static IHtmlString InlineImage(this HtmlHelper htmlHelper, string contentId, string alt = "") { | ||
return htmlHelper.Raw(string.Format("<img src=\"cid:{0}\" alt=\"{1}\"/>", contentId, alt)); | ||
} | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,32 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Net.Mail; | ||
using System.Net.Mime; | ||
using System.IO; | ||
|
||
namespace Mvc.Mailer | ||
{ | ||
namespace Mvc.Mailer { | ||
/// <summary> | ||
/// This class is a utility class for instantiating LinkedResource objects | ||
/// </summary> | ||
public class LinkedResourceProvider : ILinkedResourceProvider | ||
{ | ||
public virtual List<LinkedResource> GetAll(Dictionary<string, string> resources) | ||
{ | ||
var linkedResources = new List<LinkedResource>(); | ||
foreach (var resource in resources) | ||
{ | ||
linkedResources.Add(Get(resource.Key, resource.Value)); | ||
} | ||
return linkedResources; | ||
public class LinkedResourceProvider : ILinkedResourceProvider { | ||
public virtual List<LinkedResource> GetAll(Dictionary<string, string> resources) { | ||
return resources | ||
.Select(resource => Get(resource.Key, resource.Value)) | ||
.ToList(); | ||
} | ||
|
||
public virtual LinkedResource Get(string contentId, string filePath) | ||
{ | ||
LinkedResource resource = new LinkedResource(filePath, GetContentType(filePath)); | ||
resource.ContentId = contentId; | ||
return resource; | ||
public virtual LinkedResource Get(string contentId, string filePath) { | ||
return new LinkedResource(filePath, GetContentType(filePath)) { ContentId = contentId }; | ||
} | ||
|
||
public virtual ContentType GetContentType(string fileName) | ||
{ | ||
string ext = System.IO.Path.GetExtension(fileName).ToLower(); | ||
|
||
Microsoft.Win32.RegistryKey regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext); | ||
public virtual ContentType GetContentType(string fileName) { | ||
// Tyler: Possible null reference | ||
var ext = System.IO.Path.GetExtension(fileName).ToLower(); | ||
|
||
if (regKey != null && regKey.GetValue("Content Type") != null) | ||
{ | ||
var regKey = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(ext); | ||
if (regKey != null && regKey.GetValue("Content Type") != null) { | ||
return new ContentType(regKey.GetValue("Content Type").ToString()); | ||
} | ||
return null; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.