Using SceduledAt

I have c# code all set sending emails but I don’t know how to include scheduling into the code.
I have tried including this
string ScheduledAt = « {{params.ScheduledAt}} »;
Params.Add(« ScheduledAt », « 2023-10-13T09:15:00.00-5:00 »);

but the email gets sent immediately.
can someone explain how it should be done.

Hi @mrw02536 , which API are you using?

this one: Schedule transactional emails. ?

That doesn’t explain how I can use the c# code to use ScdeduleAt. I am using the code from your website that creates and sends the message but not how you schedule it. Am I on the wrong track using parm.add? Is the example I sent completely wrong

The code is part of a Maui project in c#. What I have will send messages

here is a section of the code where I added schedule

string HtmlContent = « 

This is an event alert email {{params.parameter}}

 »;
string TextContent = null;
string Subject = « My {{params.subject}} »;
string ReplyToName = « John Doe »;
string ReplyToEmail = « replyto@domain.com »;
SendSmtpEmailReplyTo ReplyTo = new SendSmtpEmailReplyTo(ReplyToEmail, ReplyToName);
string AttachmentUrl = null;
string stringInBase64 = « aGVsbG8gdGhpcyBpcyB0ZXN0 »;
byte Content = System.Convert.FromBase64String(stringInBase64);
string AttachmentName = « test.txt »;

        string ScheduledAt = "{{params.ScheduledAt}}";

        

        SendSmtpEmailAttachment AttachmentContent = new SendSmtpEmailAttachment(AttachmentUrl, Content, AttachmentName);
        List<SendSmtpEmailAttachment> Attachment = new List<SendSmtpEmailAttachment>();
        Attachment.Add(AttachmentContent);
        JObject Headers = new JObject();
        Headers.Add("Some-Custom-Name", "unique-id-1234");
        long? TemplateId = null;
        JObject Params = new JObject();
        Params.Add("ScheduledAt", "2023-10-14T09:40:00.00-5:00");
        Params.Add("HtmlContent", "From mrw");
        Params.Add("subject", "Event alert for today");
        List<string> Tags = new List<string>();

Did you try with scheduledAt instead of ScheduledAt ?

From what I see in the doc parameter starts will a small letter, not a capital letter

good catch but same result. I guess this approach is wrong
any ideas how to do this?
the approach was my best guess, there is no specific documentation of this except for a Jason script with no help on how to use it

here is the last part of the code that forms the send
JObject Params = new JObject();
Params.Add(« scheduledAt », « 2023-10-14T09:40:00.00-5:00 »);
Params.Add(« HtmlContent », « From mrw »);
Params.Add(« subject », « Event alert for today »);
List Tags = new List();
Tags.Add(« mytag »);
SendSmtpEmailTo1 smtpEmailTo1 = new SendSmtpEmailTo1(ToEmail, ToName);
List To1 = new List();
To1.Add(smtpEmailTo1);
Dictionary<string, object> _parmas = new Dictionary<string, object>();
_parmas.Add(« params », Params);
SendSmtpEmailReplyTo1 ReplyTo1 = new SendSmtpEmailReplyTo1(ReplyToEmail, ReplyToName);
SendSmtpEmailMessageVersions messageVersion = new SendSmtpEmailMessageVersions(To1, _parmas, null, Cc, ReplyTo1, Subject);
List messageVersiopns = new List();
messageVersiopns.Add(messageVersion);

        try
        {

            var sendSmtpEmail = new SendSmtpEmail(Email, To, null, Cc, HtmlContent, TextContent, Subject, null, null, null, null, Params, messageVersiopns, Tags);
          
            CreateSmtpEmail result = apiInstance.SendTransacEmail(sendSmtpEmail);

I just need someone who has used it to describe how

perhaps. you can decipher this

In order to define a scheduled batch or an individual scheduled message you need to make use of the scheduledAt parameter when calling the Send a Transactional Message Endpoint. This parameter takes a standard ISO formatted datetime value to which you can specify a different timezone by adding hours like so :

Have you given up with a solution?

Btw, this is where I found the c# code I am using. The scheduleAt is referred to but not how to use it.

https://developers.brevo.com/reference/sendtransacemail

to work, i believe i need sib_api version 4.02 but it requires older versions of the system.collections package and isn’t compatible with the latest stable version. The older sib v 3 will install ok but doens’t support scheduling. Can you look into this issue of why the dependencies are not up to date with sib_api

Let me check internally

here is an update. I was able to build the project by disabling the package conflict error by adding the following to the project file.
Exe
net6.0-ios
NU1605

Howevever, I still can’t get scheduled email to go. Here is the relevant code.
DateTime scheduledAt = new DateTime(2023, 10, 17, 16, 50, 15, DateTimeKind.Utc);
//Console.WriteLine(« Scheduled time = [ » + scheduledTime.ToString(« yyyy-MM-ddTHH:mm:ss.fffzzz ») + « ] »);
// TimeZoneInfo estTimeZone = TimeZoneInfo.FindSystemTimeZoneById(« Eastern Standard Time »);
// DateTime scheduledAt = TimeZoneInfo.ConvertTimeFromUtc(scheduledTimeUtc, estTimeZone);

        Console.WriteLine("Scheduled time = [" + scheduledAt.ToString("yyyy-MM-ddTHH:mm:ss.fffzzz") + "]");


        try
        {
            
            var sendSmtpEmail = new SendSmtpEmail(Email, To, null, Cc, HtmlContent, TextContent, Subject, null, null, null, null, Params, messageVersiopns, null, scheduledAt);
          
            CreateSmtpEmail result = apiInstance.SendTransacEmail(sendSmtpEmail);

when I put it a date that’s before the current date the application output gives me this warning.
2023-10-17 13:51:31.385 MAUISql[63158:1247193] Scheduled time = [2023-10-17T16:50:15.000+00:00]
Thread started: #13
Thread started: #14
Error calling SendTransacEmail: {« code »:« invalid_parameter »,« message »:« Scheduled date should not be less than current date »}

when I put a good date in I get this

2023-10-17 13:52:52.291 MAUISql[63194:1249275] Scheduled time = [2023-10-17T18:50:15.000+00:00]
2023-10-17 13:52:52.408 MAUISql[63194:1249310] Warning: observer object was not disposed manually with Dispose()
2023-10-17 13:52:52.409 MAUISql[63194:1249310] Warning: observer object was not disposed manually with Dispose()
Thread started: #14
Thread started: #15
{
« messageIds »: [
« 202311171752.59998685814.1@smtp-relay.mailin.fr »
]
}

notice the message id, however, nothing gets sent at the scheduled time.

When I null out the scheduledAt.
var sendSmtpEmail = new SendSmtpEmail(Email, To, null, Cc, HtmlContent, TextContent, Subject, null, null, null, null, Params, messageVersiopns, null, null);

the email is sent immediatly.

can you see any errors?

This is the full code snippet that doesn’t work

DateTime scheduledTimeUtc = new DateTime(2023, 10, 18, 23, 25, 15, DateTimeKind.Utc);
TimeZoneInfo estTimeZone = TimeZoneInfo.FindSystemTimeZoneById(« Eastern Standard Time »);
DateTime scheduledAt = TimeZoneInfo.ConvertTimeFromUtc(scheduledTimeUtc, estTimeZone);

Console.WriteLine(« Scheduled time = [ » + scheduledAt.ToString(« yyyy-MM-ddTHH:mm:ss.fffzzz ») + « ] »);
try
{

var sendSmtpEmail = new SendSmtpEmail(Email, To, null, Cc, HtmlContent, TextContent, Subject, null, null, null, null, Params, messageVersiopns, Tags, scheduledAt);

CreateSmtpEmail result = apiInstance.SendTransacEmail(sendSmtpEmail);

while. Your experts review the problem here is the latest…

Trying to install the nugget package sib_api v. 4.02 creates a nu1605 error. I am able to override the error by adding this:

4

To my project file, with this I can install the v. 4.02 package and use mail scheduling.

This is the code I use for that.

DateTime scheduledAt = DateTime.ParseExact(« 2023-10-18T10:15:00.000-05:00 », « yyyy-MM-ddTHH:mm:ss.fffzzz », System.Globalization.CultureInfo.InvariantCulture);

Console.WriteLine(« Scheduled time = [ » + scheduledAt + « ] »);

try
{

var sendSmtpEmail = new SendSmtpEmail(Email, To, null, Cc, HtmlContent, TextContent, Subject, null, null, null, null, Params, messageVersiopns, null, scheduledAt);

CreateSmtpEmail result = apiInstance.SendTransacEmail(sendSmtpEmail);

I don’t get any rfc3339 format errors and the program runs. If there were errors I would get a format error on the console.This is the error I get with the incorrect format

Error calling SendTransacEmail: {« code »:« invalid_parameter »,« message »:"Scheduled date is not valid. It should be in standard RFC3339 format”}

When the time is less than the current time I also get an error on the console

Error calling SendTransacEmail: {« code »:« invalid_parameter »,« message »:« Scheduled date should not be less than current date »}

Since there are no errors and I am not getting a scheduled email, I presume there is a problem at your end.

Can you have someone look into this for me

Richard Weiss

Hi Richard,

I am currently looking for a C# expert internally. It takes a bit of time but I’m still on it. I’ll let you know. Thanks for all these details this will help us understand the issue.

Hi Richard, it appears there was an issue on our side in the last days. We received an overload of requests regarding this scheduling feature. This should be fine today or tomorrow. So if you still can’t send it tomorrow, can you please let me know? Thanks

Thanks, just let me know what I will need to do at my end.