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

Ability to apply a CC address #93

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
22 changes: 22 additions & 0 deletions src/Postmark.Tests/ClientSendingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,28 @@ await _client.SendMessageAsync(
"If it has been more than 45 days since these tests have been run on this server, try re-running this test."
);
}

[Fact]
public async void Client_CanSendASingleMessage_With_CC()
{
var result = await _client.SendMessageAsync(WRITE_TEST_SENDER_EMAIL_ADDRESS,
WRITE_TEST_EMAIL_RECIPIENT_ADDRESS,
String.Format("Integration Test - {0}", TESTING_DATE),
String.Format("Plain text body, {0}", TESTING_DATE),
String.Format("Testing the Postmark .net client, <b>{0}</b>", TESTING_DATE),
new Dictionary<string, string>()
{
{ "X-Integration-Testing" , TESTING_DATE.ToString("o")}
},
new Dictionary<string, string>() {
{"test-metadata", "value-goes-here"},
{"more-metadata", "more-goes-here"}
}, cc: WRITE_TEST_EMAIL_RECIPIENT_ADDRESS);

Assert.Equal(PostmarkStatus.Success, result.Status);
Assert.Equal(0, result.ErrorCode);
Assert.NotEqual(Guid.Empty, result.MessageID);
}

[Fact]
public async void Client_CanSendASingleMessage()
Expand Down
4 changes: 3 additions & 1 deletion src/Postmark/Model/PostmarkMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@ public PostmarkMessage()
/// <param name = "headers">A collection of additional mail headers to send with the message. (optional)</param>
/// <param name = "metadata">A dictionary of metadata to send with the message. (optional)</param>
/// <param name="messageStream">The message stream used to send this message. If not provided, the default transactional stream "outbound" will be used. (optional)</param>
/// <param name="cc">An email address for a CC recipient.</param>
public PostmarkMessage(string from, string to, string subject, string textBody, string htmlBody,
HeaderCollection headers = null, IDictionary<string, string> metadata = null, string messageStream = null) : base()
HeaderCollection headers = null, IDictionary<string, string> metadata = null, string messageStream = null, string cc = null) : base()
{
From = from;
To = to;
Expand All @@ -34,6 +35,7 @@ public PostmarkMessage(string from, string to, string subject, string textBody,
Headers = headers ?? new HeaderCollection();
Metadata = metadata;
MessageStream = messageStream;
Cc = cc;
}

/// <summary>
Expand Down
5 changes: 3 additions & 2 deletions src/Postmark/PostmarkClientExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ public static class PostmarkClientExtensions
/// <param name="htmlBody">The HTML Body to be used for the message, this may be null if TextBody is set.</param>
/// <param name="headers">A collection of additional mail headers to send with the message.</param>
/// <param name="messageStream">The message stream used to send this message.</param>
/// <param name="cc">An email address for a CC recipient.</param>
/// <returns>A <see cref = "PostmarkResponse" /> with details about the transaction.</returns>
public static async Task<PostmarkResponse> SendMessageAsync(this PostmarkClient client,
string from, string to, string subject, string textBody, string htmlBody,
IDictionary<string, string> headers = null,
IDictionary<string, string> metadata = null,
string messageStream = null)
string messageStream = null, string cc = null)
{
var message = new PostmarkMessage(from, to, subject, textBody, htmlBody,
new HeaderCollection(headers), metadata, messageStream);
new HeaderCollection(headers), metadata, messageStream, cc);
return await client.SendMessageAsync(message);
}

Expand Down