79151891

Date: 2024-11-03 01:30:59
Score: 0.5
Natty:
Report link

I can't comment on the above-accepted answer; hence, I am providing another answer.

Please note a few changes for the sample code to work in 2024.

  1. connection string:
    • remove https:// as it is appended by the library.
    • remove the leading / at the end of the communication-server. It leads to the wrong auth header and results in 401.

example:

  1. The Azure rest API requires attachments to be passed in even though you have no attachments. here is the updated payload that works.
payload: = emails.Payload {
  Headers: emails.Headers {
    ClientCorrelationID: "some-correlation-id",
    ClientCustomHeaderName: "some-custom-header",
  },
  SenderAddress: "<[email protected]>",
  Content: emails.Content {
    Subject: "Fabric tenant abcde wants to upgrade to paid offer",
    PlainText: "This is being generated from dev-server.",
    HTML: "<p>This is a <strong>test</strong> email.</p>",
  },
  Recipients: emails.Recipients {
    To: [] emails.ReplyTo {
      {
        Address: "[email protected]",
        DisplayName: "Garima Bathla",
      },
    },
  },
  Attachments: [] emails.Attachment {},
  UserEngagementTrackingDisabled: false,
}
  1. The sender's email address needs to be in this format:
SenderAddress: "<[email protected]>",
Reasons:
  • RegEx Blacklisted phrase (1): can't comment
  • Long answer (-1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Garima Bathla