Csharp SDK tutorial

Last Updated: Dec 18, 2017

Create an AccessKey

  1. Log on to the AccessKey console.
  2. Click Create AccessKey at the upper-right corner of the page.
  3. Read API Terms of Use, and click Agree and Create.

Note: You can use the AccessKey created with Alibaba Cloud Resource Access Management service.

Install the C# SDK

Development environment

Alibaba Cloud C# SDK supports .Net Framework 2.0 or later.

Download the SDK

Click here to download the SDK directly.

Install the SDK

  1. You can find the files “aliyun-net-sdk-core.dll” and “aliyun-net-sdk-dm.dll” in the downloaded package.
  2. Right-click Project on your Visual Studio, and click Add Reference > Browse (if you are using MonoDevelop, follow the appropriate DLL import method to import the .dll files). Select the .dll files, and click OK.

Now you can use Alibaba Cloud DirectMail C# SDK in your project.

Email sending example

Take calling the API to send a single email as an example (for how to call the interface, see SingleSendMail):

  1. using Aliyun.Acs.Core;
  2. using Aliyun.Acs.Core.Exceptions;
  3. using Aliyun.Acs.Core.Profile;
  4. using Aliyun.Acs.Dm.Model.V20151123;
  5. namespace ConsoleApp
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. IClientProfile profile = DefaultProfile.GetProfile("cn-hangzhou", "<your accessKey", "<your accessSecret>");
  12. IAcsClient client = new DefaultAcsClient(profile);
  13. SingleSendMailRequest request = new SingleSendMailRequest();
  14. try {
  15. request.AccountName = "Sender address created in the console";
  16. request.FromAlias = "Sender nickname";
  17. request.AddressType = 1;
  18. request.TagName = "Tag created in the console";
  19. request.ReplyToAddress = true;
  20. request.ToAddress = "Destination address";
  21. request.Subject = "Subject";
  22. request.HtmlBody = "Body";
  23. SingleSendMailResponse httpResponse = client.GetAcsResponse(request);
  24. } catch (ServerException e) {
  25. e.printStackTrace();
  26. }
  27. catch (ClientException e) {
  28. e.printStackTrace();
  29. }
  30. }
  31. }
  32. }
Thank you! We've received your feedback.