Csharp SDK tutorial

Last Updated: Aug 16, 2017

Create an Access Key

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

Note: You can use the Access Key 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

Download the SDK directly.

Install the SDK

  1. You can find the “aliyun-net-sdk-core.dll” and “aliyun-net-sdk-dm.dll” files in the unzipped files.
  2. Right-click your Visual Studio project, and click Add Reference > Browse (If you are using MonoDevelop, follow the appropriate DLL import method to import the .dll file). Select the above .dll files, and click OK.
    Now you can use Alibaba Cloud DirectMail C# SDK in your project.

Email sending example

Take calling the API sending single mail as an example (For how to call the interface, refer to 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 = "Mail 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.