using (var svc = new AdministrationService.AdministrationClient())
{
var request = new AdministrationService.ManagementGroupRequestOfEmailSend();
request.Token = "Token";
request.ManagementGroup = "Management group";
var emailSend = new AdministrationService.EmailSend();
emailSend.EmailTemplateId = "Email template";
emailSend.CampaignName = string.Empty;
emailSend.CampaignSegmentName = string.Empty;
var attachmentFile = new AdministrationService.EmailAttachment();
attachmentFile.FileName = "File1.txt";
attachmentFile.Data = new byte[1024];
emailSend.Attachments = new AdministrationService.EmailAttachment[] { attachmentFile };
var labelCode = new AdministrationService.MergeLabelCode();
labelCode.LabelCode = "LC";
labelCode.LabelCodeName = string.Empty;
emailSend.LabelCodes = new AdministrationService.MergeLabelCode[] { labelCode };
var logAgainstEntity = new AdministrationService.CampaignListEntity();
logAgainstEntity.EntityRSN = "Log against entity RSN string";
logAgainstEntity.EntityType = "Person";
emailSend.LogAgainstEntities = new AdministrationService.CampaignListEntity[] { logAgainstEntity };
var mergeEntity = new AdministrationService.CampaignListEntity();
mergeEntity.EntityRSN = "Merge entity RSN string";
mergeEntity.EntityType = "Person";
emailSend.MergeEntities = new AdministrationService.CampaignListEntity[] { mergeEntity };
var mergeField = new AdministrationService.MergeField();
mergeField.FieldName = "WelcomeMessage";
mergeField.FieldValue = "Hello John,";
emailSend.MergeFields = new AdministrationService.MergeField[] { mergeField };
request.Value = emailSend;
AdministrationService.ResultOflong result = svc.SendEmailFromTemplateForCampaignWithAttachments(request);
if (result.FaultCode == 0)
{
}
else
{
throw new Exception(result.FaultDescription);
}
}