kalveygroup.com – Previously, we have published a post that explains on Alibaba Cloud SDK which you can find in this link. In that post, we have covered several information and based on the information, one of the advantages of using Alibaba Cloud SDK is that Alibaba Cloud SDK enables developer to create system efficiently with minimal effort.

In this occasion, we’ll be covering on how to integrate Alibaba Cloud DirectMail SDK with your .NET project. The sample project will be created using Visual Studio 2019 Community Edition, and built using C# programming language.


1. Alibaba Cloud DirectMail SDK, which you can download here
2. Programming IDE that supports .NET Framework
3. Alibaba Cloud AccessKey. If you don’t have one, please refer to this article as it covers how to generate AccessKey

Installing DirectMail SDK

1. Extract the downloaded Alibaba Cloud Direct Mail SDK. It should have two files inside the zip file.

2. Create your C# project using Visual Studio, and take a look on your solution explorer. Right Click on the References, and click on Add Reference tab

3. Navigate to the folder that contains the DirectMail SDK and add it to the project. If you have added the SDK, it will shows like the image below.

4. The installation of SDK should be now completed and we can proceed to the next step.

Sending Email using DirectMail SDK

1. Add these references to the project

using Aliyun.Acs.Core;
using Aliyun.Acs.Core.Exceptions;
using Aliyun.Acs.Core.Profile;
using Aliyun.Acs.Dm.Model.V20151123;

2. Next, we will be using our SecretKey and AccessKey to send email. This code sample will let you to send email using DirectMail SDK

IClientProfile profile = DefaultProfile.GetProfile("regionId", "AccessKey", "SecretKey");
IAcsClient client = new DefaultAcsClient(profile);
SingleSendMailRequest request = new SingleSendMailRequest();
try {
        request.AccountName = "Sender address (You can check it on your console)";
        request.FromAlias = "Sender alias";
        request.AddressType = 1;
        request.TagName = "Tag (You can check it on your console)";
        request.ReplyToAddress = true;
        request.ToAddress = "Recepient Email";
        request.Subject = "The Email Subject";
        request.HtmlBody = "The Email Body, using HTML";
        SingleSendMailResponse httpResponse = client.GetAcsResponse(request);
} catch (ServerException e) {
} catch (ClientException e) {