To publish a message to an SNS topic in C#, use the Amazon Web Services (AWS) SDK for .NET.
First, install the AWS SDK for .NET using NuGet:
main.cs27 chars2 lines
Then create an instance of the AmazonSimpleNotificationServiceClient
class and call its PublishAsync
method, passing in the topic arn and message text as parameters:
main.cs219 chars7 lines
Make sure to replace the topicArn
value with the actual ARN of your SNS topic.
The PublishAsync
method returns a PublishResponse
object, which contains information about the published message (such as its message ID).
gistlibby LogSnag