mailjet / mailjet-apiv3-php

[API v3] Mailjet PHP Wrapper
http://dev.mailjet.com
MIT License
267 stars 86 forks source link

Examples either do not compile or email is not sent #292

Closed ancich closed 4 months ago

ancich commented 5 months ago

I am using c# in Visual Studio. I have tried console apps and winform apps (both .Net 6)

for the longest time The following line kept returning the error of returning a null. It seems only after making subaccount api keys that it would 'run' without causing a null error...

        MailjetClient client = new MailjetClient("cc08a--public key---0fb8868",
            "5ff01--secret key--------6dc1")
        {
            // version = ApiVersion.V3_1,
        };

The following method is called from my main() using the line await SendEmailAsync("p------y@yahoo.com", "heelllloooo", "This is the message buddyyyyyyyyy"); The code is straight from github. I only changed the source and destination email address to both be my own email address

   public async Task SendEmailAsync(string email, string subject, string htmlMessage)
   {
       MailjetClient client = new MailjetClient("cc08a--public key---0fb8868",
           "5ff01--secret key--------6dc1")
       {
           // version = ApiVersion.V3_1,  ... had to  comment out otherwise it creates an error.
       };
       MailjetRequest request = new MailjetRequest
       {
           Resource = Send.Resource,
       }
          .Property(Send.Messages, new JArray {
   new JObject {
    {"From", new JObject {
     {"Email", email},
     {"Name", "Mailjet Pilot"}
     }},
    {"To", new JArray {
     new JObject {
      {"Email", email},
      {"Name", "Hello"}
      }
     }},
    {"Subject", subject},
    {"HTMLPart", htmlMessage}
    }
              });
       MailjetResponse response = await client.PostAsync(request);

   }

If I step through the code, the response's ErrorInfo sasy "at least FromEmail or sender must be provided". Of course it is provided! So what is going on?? I am using the same email address as the one I used to sign up with Mailjet, for both the From and To email addresses.

ancich commented 4 months ago

Thanks for coming out...

oleksandr-mykhailenko commented 4 months ago

Hello @ancich This is not a php example. Please, as a question to repo with C#. I cannot' help you with this