Issue with SendMessage API – "Index was outside the bounds of the array."
Problem reported by yerim kim - 8/26/2025 at 6:37 PM
Submitted

Hello,

I am currently evaluating SmarterMail with the Free license before moving forward with a purchase.

As part of the testing, I am developing an API integration for sending and receiving mail. Receiving works without issues, but I am running into a problem when sending mail using the SendMessage API.

Environment: ASP.NET C#

The problem is that regardless of which parameters I include in the request, the API always responds with:

"Index was outside the bounds of the array."

Here is the request I am making:

var mailData = new
{
    to = "\"test@receive.com\" <test@receive.com>;",
    ownerEmailAddress = "send@test.com",
    from = "send@test.com",
    subject = "test",
    messageHTML = "test"
};

I have checked the community forum, but I have not been able to find a post that addresses this specific error.

Could you please advise what might be causing this?

  • Is there an issue with the request payload format?

  • Or is there a domain/mailbox configuration setting in SmarterMail that I need to adjust?

The API documentation does not provide enough information for me to determine the cause. Any guidance or suggestions would be greatly appreciated.

Thank you.

Zach Sylvester Replied
Employee Post
Try setting the To like this 
to = "test@receive.com"

Let me know if this helps.
Zach Sylvester Software Developer SmarterTools Inc. www.smartertools.com
yerim kim Replied

Thank you for your response. However, I am still encountering the same error.

Just in case it helps, I am also attaching the HTTP request code below.

Here is the code I am using to make the request.

using (var client = new HttpClient())
                {
                    var mailData = new
                    {
                        to = "test@receive.com",
                        ownerEmailAddress = "send@test.com",
                        from = "send@test.com",
                        subject = "test",
                        messageHTML = "test"
                    };

                    var json = JsonConvert.SerializeObject(mailData);
                    var content = new StringContent(json, Encoding.UTF8, "application/json");
                    client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);

                    var response = client.PostAsync(uri, content).Result;
                    dynamic result = JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result);

                    if (!response.IsSuccessStatusCode)
                    {
                        throw new Exception($"Sending message failed with status code {response.StatusCode} / {result.message}");
                    }

                    return result;
                }
Index was outside the bounds of the array. -> This error message is coming from the value of result.message in the response.
CLEBER SAAD Replied
Sounds good if API have some logs with more information.
In our integration we found some  problems and some enum's not documented.
yerim kim Replied
For anyone else experiencing the same issue:
Try adding the selectedFrom field to your request.

selectedFrom = ":test@test.com"

Reply to Thread

Enter the verification text