Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Email.cs #105

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/Postal/Email.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,23 @@ public Email(string viewName)
ViewData = new ViewDataDictionary(this);
ImageEmbedder = new ImageEmbedder();
}

/// <summary>
/// Creates a new Email, that will render the given view.
/// </summary>
/// <param name="viewName">The name of the view to render</param>
/// <param name="model">The model associate of the view to render</param>
public Email(string viewName, object model)
{
if (viewName == null) throw new ArgumentNullException("viewName");
if (string.IsNullOrWhiteSpace(viewName)) throw new ArgumentException("View name cannot be empty.", "viewName");
if (model == null) throw new ArgumentNullException("model");

Attachments = new List<Attachment>();
ViewName = viewName;
ViewData = new ViewDataDictionary(model);
ImageEmbedder = new ImageEmbedder();
}

/// <summary>Create an Email where the ViewName is derived from the name of the class.</summary>
/// <remarks>Used when defining strongly typed Email classes.</remarks>
Expand Down Expand Up @@ -120,4 +137,4 @@ string DeriveViewNameFromClassName()
return viewName;
}
}
}
}