public String publishingBulkEmail(String apiKey, String contactfileName, String fromName, String fromAddress, String subject, String reportReceiveAddress, String mailBody) { DialogueSettingDao DialogueSettingDao = new DialogueSettingDao(); DialogueSettingBO DB_DialogueSetting = DialogueSettingDao.Get(apiKey); Authorization authorization = new Authorization(); authorization.client = DB_DialogueSetting.client; authorization.username = DB_DialogueSetting.username; authorization.password = DB_DialogueSetting.password; DialogueSetting dialogueSetting = new DialogueSetting(); dialogueSetting.contactDatabaseId = DB_DialogueSetting.contactDatabaseId; dialogueSetting.workspaceId = DB_DialogueSetting.workspaceId; dialogueSetting.emailTypeId = DB_DialogueSetting.emailTypeId; dialogueSetting.ftpAccountId = DB_DialogueSetting.ftpAccountId; String prefix = DB_DialogueSetting.prefix; String sequence = DateTime.Now.ToString("yyyyMMddHHmmssfffffff"); ContactGroup contactGroup = new ContactGroup(); contactGroup.groupLabel = prefix + sequence; contactGroup.groupName = prefix + sequence; DirectEmail directEmail = new DirectEmail(); directEmail.emailLabel = prefix + sequence; directEmail.emailName = prefix + sequence; directEmail.subject = subject; directEmail.description = subject; directEmail.fromName = fromName; directEmail.fromAddress = fromAddress; if (String.IsNullOrEmpty(reportReceiveAddress)) { directEmail.reportReceiveAddress = fromAddress; } else { directEmail.reportReceiveAddress = reportReceiveAddress; } directEmail.htmlContent = mailBody; DialogueService_new dialogueService_new = new DialogueService_new(authorization.client, authorization.username, authorization.password, null); return dialogueService_new.publishingBulkEmail(dialogueSetting, contactGroup, contactfileName, directEmail); }
public String sendMail(String APIKey, String fromName, String fromEmail, String subject, string mailContent, String toEmail, DateTime scheduleTime) { if (!APIKey.Equals("MjU4MDI1ODCzAn45YUUpJw")) { throw new Exception("API认证失败,请确认你的APIkey是否正确."); } Authorization authorization = new Authorization(); authorization.client = "Training"; authorization.username = "******"; authorization.password = "******"; DialogueService_new dialogueService_new = new DialogueService_new(authorization.client, authorization.username, authorization.password, null); DialogueSetting dialogueSetting = new DialogueSetting(); dialogueSetting.contactDatabaseId = "MjU4MDI1ODCzAn45YUUpJw"; dialogueSetting.workspaceId = "MjAzNDIwMzTIkkBLrbUiiA"; dialogueSetting.emailTypeId = "MTgwNTE4MDVA5rEBE89J_w"; DirectEmail directEmail = new DirectEmail(); String sequence = DateTime.Now.ToString("yyyyMMddHHmmssfffffff"); directEmail.emailLabel = sequence; directEmail.emailName = sequence; directEmail.subject = subject; directEmail.description = subject; directEmail.fromName = fromName; directEmail.fromAddress = fromEmail; directEmail.reportReceiveAddress = fromEmail; directEmail.htmlContent = mailContent; directEmail.sheduleTime = scheduleTime; KeyValuePair[] ContactInfos = new KeyValuePair[1]; KeyValuePair ContactInfo = new KeyValuePair(); ContactInfo.key = "email"; ContactInfo.value = toEmail; ContactInfos[0] = ContactInfo; return dialogueService_new.sendSingleEmail(dialogueSetting, directEmail, ContactInfos); }
public SendSmsResult sendSMS(String apiKey, string mobile, string time, string content) { DialogueSettingDao DialogueSettingDao = new DialogueSettingDao(); DialogueSettingBO DB_DialogueSetting = DialogueSettingDao.Get(apiKey); Authorization authorization = new Authorization(); authorization.client = DB_DialogueSetting.client; authorization.username = DB_DialogueSetting.username; authorization.password = DB_DialogueSetting.password; string account = DB_DialogueSetting.sms_account; string password = DB_DialogueSetting.sms_password; string pid = DB_DialogueSetting.sms_pid; DialogueService_new dialogueService_new = new DialogueService_new(authorization.client, authorization.username, authorization.password, null); return dialogueService_new.sendSMS(account, password, mobile, pid, time, content); }
public ReportData getRerportByJobId(String apiKey, String publishId, DateTime startTime, DateTime endTime) { DialogueSettingDao DialogueSettingDao = new DialogueSettingDao(); DialogueSettingBO DB_DialogueSetting = DialogueSettingDao.Get(apiKey); Authorization authorization = new Authorization(); authorization.client = DB_DialogueSetting.client; authorization.username = DB_DialogueSetting.username; authorization.password = DB_DialogueSetting.password; DialogueService_new dialogueService_new = new DialogueService_new(authorization.client, authorization.username, authorization.password, null); return dialogueService_new.getRerportByJobId(publishId, startTime, endTime); }
public void exportReportToFtp(String apiKey, String fileNamePrefix, DateTime startTime, DateTime endTime) { DialogueSettingDao DialogueSettingDao = new DialogueSettingDao(); DialogueSettingBO DB_DialogueSetting = DialogueSettingDao.Get(apiKey); Authorization authorization = new Authorization(); authorization.client = DB_DialogueSetting.client; authorization.username = DB_DialogueSetting.username; authorization.password = DB_DialogueSetting.password; DialogueService_new dialogueService_new = new DialogueService_new(authorization.client, authorization.username, authorization.password, null); dialogueService_new.exportReportToFtp(DB_DialogueSetting.contactDatabaseId, DB_DialogueSetting.ftpAccountId, fileNamePrefix, startTime, endTime); }
public CSVReportData exportReport(String apiKey, DateTime startTime, DateTime endTime) { DialogueSettingDao DialogueSettingDao = new DialogueSettingDao(); DialogueSettingBO DB_DialogueSetting = DialogueSettingDao.Get(apiKey); Authorization authorization = new Authorization(); authorization.client = DB_DialogueSetting.client; authorization.username = DB_DialogueSetting.username; authorization.password = DB_DialogueSetting.password; DialogueService_new dialogueService_new = new DialogueService_new(authorization.client, authorization.username, authorization.password, null); ExportReportData report = dialogueService_new.exportReport(DB_DialogueSetting.contactDatabaseId, startTime, endTime); CSVReportData csvReportData = new CSVReportData(); csvReportData.sent = Encoding.UTF8.GetString(report.sent); csvReportData.opened = Encoding.UTF8.GetString(report.opened); csvReportData.clicked = Encoding.UTF8.GetString(report.clicked); csvReportData.bounced = Encoding.UTF8.GetString(report.bounced); return csvReportData; }
public String registerContact(String apiKey, KeyValuePair[] ContactInfos) { DialogueSettingDao DialogueSettingDao = new DialogueSettingDao(); DialogueSettingBO DB_DialogueSetting = DialogueSettingDao.Get(apiKey); Authorization authorization = new Authorization(); authorization.client = DB_DialogueSetting.client; authorization.username = DB_DialogueSetting.username; authorization.password = DB_DialogueSetting.password; DialogueSetting dialogueSetting = new DialogueSetting(); dialogueSetting.contactDatabaseId = DB_DialogueSetting.contactDatabaseId; dialogueSetting.workspaceId = DB_DialogueSetting.workspaceId; dialogueSetting.directEmailId = DB_DialogueSetting.directEmailId; DialogueService_new dialogueService_new = new DialogueService_new(authorization.client, authorization.username, authorization.password, null); return dialogueService_new.registerContact(dialogueSetting, ContactInfos); }
public CSVReportData exportReport(String APIKey, DateTime startTime, DateTime endTime) { if (!APIKey.Equals("MjU4MDI1ODCzAn45YUUpJw")) { throw new Exception("API认证失败,请确认你的APIkey是否正确."); } Authorization authorization = new Authorization(); authorization.client = "Training"; authorization.username = "******"; authorization.password = "******"; if (endTime <= startTime) { throw new Exception("开始时间要小于等于结束时间"); } if (startTime.AddHours(8) < endTime) { throw new Exception("时间间隔必须在8小时之内"); } DialogueService_new dialogueService_new = new DialogueService_new(authorization.client, authorization.username, authorization.password, null); String contactDatabaseId = "MjU4MDI1ODCzAn45YUUpJw"; ExportReportData report = dialogueService_new.exportReport(contactDatabaseId, startTime, endTime); CSVReportData csvReportData = new CSVReportData(); csvReportData.sent = Encoding.UTF8.GetString(report.sent); csvReportData.opened = Encoding.UTF8.GetString(report.opened); csvReportData.clicked = Encoding.UTF8.GetString(report.clicked); csvReportData.bounced = Encoding.UTF8.GetString(report.bounced); return csvReportData; }
static void Main(string[] args) { //String client = "IPSOS API";//Training"; //String userName = "******";//[email protected]"; //String password = "******"; //String databaseID = "MjUyMTI1MjHJ69MSWqS6mQ"; //String ftpAccountId = "NTQwNTQwNTQQosYwP6thgg"; String client = "Training"; String userName = "******"; String password = "******"; // String databaseID = "MjU4MDI1ODCzAn45YUUpJw";//"MjU1MTI1NTFFUVus6S83qA"; //String client = "51job"; //String userName = "******"; //String password = "******"; //String databaseID = "MjU1ODI1NTgL21MIxlZDCQ"; //String ftpAccountId = "NTM4NTM4NTMEfaWC25Hk0Q"; DialogueService_new dialogueService = new DialogueService_new(client, userName, password, null); //String mailJobId = "MTA0ODQyOTKMdCDprzC_oRpaAAO2LvZr"; //String databaseID = "MjU1ODI1NTgL21MIxlZDCQ"; DateTime startTime = DateTime.Now.AddDays(-1); DateTime endTime = DateTime.Now; //dialogueService.exportReportToFtp(databaseID,ftpAccountId, startTime, endTime,ReportType.SENT); ReportData mailReport = dialogueService.getRerportByJobId("MTA1MzU3NDKMdCDprzC_oRpaAAO2LvZr", startTime, endTime); Console.WriteLine("Sent**********************"); Console.WriteLine(mailReport.sent); Console.WriteLine("opened**********************"); Console.WriteLine(mailReport.opened); Console.WriteLine("clicked**********************"); Console.WriteLine(mailReport.clicked); Console.WriteLine("bounced**********************"); Console.WriteLine(mailReport.bounced); Console.ReadLine(); DialogueSetting dialogueSetting = new DialogueSetting(); dialogueSetting.contactDatabaseId = "MjU1MTI1NTFFUVus6S83qA"; dialogueSetting.workspaceId = "MjAwNzIwMDdKRmT4g3bWOg"; dialogueSetting.emailTypeId = "MTc2MDE3NjBcUp_pC*h71w"; DirectEmail directEmail = new DirectEmail(); String sequence = DateTime.Now.ToString("yyyyMMddHHmmssfffffff"); directEmail.emailLabel = sequence; directEmail.emailName = sequence; directEmail.subject = "单个邮件测试"; directEmail.description = "API邮件测试"; directEmail.fromName = "周安平"; directEmail.fromAddress = "*****@*****.**"; directEmail.reportReceiveAddress = "*****@*****.**"; directEmail.htmlContent = "Hello World"; KeyValuePair[] ContactInfos = new KeyValuePair[3]; KeyValuePair ContactInfo = new KeyValuePair(); ContactInfo.key = "email"; ContactInfo.value = "*****@*****.**"; ContactInfos[0] = ContactInfo; ContactInfo = new KeyValuePair(); ContactInfo.key = "username"; ContactInfo.value = "周安平"; ContactInfos[1] = ContactInfo; ContactInfo = new KeyValuePair(); ContactInfo.key = "password"; ContactInfo.value = "12234234"; ContactInfos[2] = ContactInfo; directEmail.subject = "单个邮件测试"; dialogueService.sendSingleEmail(dialogueSetting, directEmail, ContactInfos); dialogueSetting.directEmailId = "MzczMDk1Mzc98HDFHcJFcg"; directEmail.subject = "注册邮件测试"; dialogueService.registerContact(dialogueSetting, ContactInfos); ContactGroup contactGroup = new ContactGroup(); contactGroup.groupLabel = "Demo Group"; contactGroup.groupName = "demogroup1"; ContactFileInfo importFiles = new ContactFileInfo(); importFiles.fileType = cn.tripolis.dialogue.import.fileExtension.CSV; importFiles.filename = "Contacts.csv"; importFiles.csvDilimiter = ContactFileInfo.DEFAULT_CSV_DELIMIT; importFiles.fileContent = System.IO.File.ReadAllBytes("../../Example/Contacts.csv"); directEmail.subject = "小批量邮件测试"; dialogueService.publishingSmallScaleEmail(dialogueSetting, contactGroup, importFiles, directEmail); dialogueSetting.ftpAccountId = "NTM5NTM5NTNW_uqPXJDMzQ"; directEmail.subject = "大批量邮件测试"; dialogueService.publishingBulkEmail(dialogueSetting, contactGroup, "Contacts.xls", directEmail); System.Console.WriteLine("Finish Action"); System.Console.ReadLine(); }