How to send email with attachment in c#

private void SendMailWithoutPortalFieldsInformation(List<string> toList, string fromAddress, string fromTitle, string subject, string portalId, string messageBodyText, string filename, string filemimetype, string filesource)
            MailMessage mailMessage = new MailMessage();
            mailMessage.From = new MailAddress(fromAddress, fromTitle);

            foreach (var item in toList)
                mailMessage.To.Add(new MailAddress(item));

            mailMessage.Subject = subject;
            mailMessage.IsBodyHtml = true;
            mailMessage.Body = messageBodyText;

            SmtpClient smtpClient = new SmtpClient();
            smtpClient.UseDefaultCredentials = false;

            smtpClient.Host = "";
            smtpClient.Port = 123; //Port number
            smtpClient.EnableSsl = true;
            smtpClient.Credentials = new System.Net.NetworkCredential("userame", "password");

            if (!string.IsNullOrEmpty(filename) && !string.IsNullOrEmpty(filemimetype) && !string.IsNullOrEmpty(filesource))
                var fileData = filesource.Replace("data:" + filemimetype + ";base64,", "");
                byte[] bytes = Convert.FromBase64String(fileData);
                Stream stream = new MemoryStream(bytes);
                mailMessage.Attachments.Add(new System.Net.Mail.Attachment(stream, filename, filemimetype));


#c, #email, #email-attacment, #send-mail, #smtp

MS Dynamics Crm 2016 connection and retrive multiple data

This feature came to ms dynamics crm 2016 SDK and using to Microsoft.Xrm.Tooling.Connector.dll

static void Main(string[] args)
    IOrganizationService service;
    CrmServiceClient crmSvc = null;

    crmSvc = new CrmServiceClient(new System.Net.NetworkCredential("username", "password", "domain"), AuthenticationType.AD, "organizationurl", "443", "organizationname", useUniqueInstance: false, useSsl: true);

    service = crmSvc.OrganizationServiceProxy;

    QueryExpression qe = new QueryExpression();
    qe.ColumnSet = new ColumnSet(true);
    qe.EntityName = "account";
    qe.Criteria = new FilterExpression();
    qe.Criteria.AddCondition(new ConditionExpression("name", ConditionOperator.Equal, "huseyin"));

    var list = service.RetrieveMultiple(qe);



#c, #console, #crm, #dynamics-crm, #dynamics-crm-2016, #retrieve-multiple-data-2016