I a have a SharePoint 2013 list. This list has a visual studio sequential workflow. This Form will go to director then if he approved it will go to the approver to approve and then it will reach to the manager to fill the email field and to approve. When the manager approved, the status will change to Completed. I want to make an event receiver to send an email to the email that the manager added and the email should contain uniform Body every time, the subject should be changed every time. Also it should contain attachment property that enable the manager to attach document. And finally the manager will addCC person and will send the email. How Can I do it since I am new in SharePoint. If you have code sample will help me, please put it here.
It should attach document or image from desktop.
I am using the code in this account SPUtility.SendEmail() with attachment (.ics files) Put I change it to the following:
My questions are: 1. Is this code will attach from desktop?
what should I write instead of insert_ attachment_url?
Can someone take a look on a code and tell me the wrong things?
base.ItemAdded(properties); SPListItem listItem = properties.ListItem; String OS = properties.AfterProperties ["Status"].ToString(); String Email = listItem ["EmailAddress"].ToString(); //Get the Sharepoint SMTP information from the SPAdministrationWebApplication string smtpServer = SPAdministrationWebApplication.Local.OutboundMailServiceInstance.Server.Address; string smtpFrom = SPAdministrationWebApplication.Local.OutboundMailSenderAddress; //Create the mail message and supply it with from and to info //****it will be change**** MailMessage mailMessage = new MailMessage(smtpFrom, companyEmail); if (OS == "completed") { //Set the subject and body of the message mailMessage.Subject = " "; mailMessage.IsBodyHtml = true; mailMessage.Body = " Your request is ready "; mailMessage.To.Add(new MailAddress(Email)); mailMessage.From = new MailAddress(smtpFrom); //Download the content of the file with a WebClient WebClient webClient = new WebClient(); //Supply the WebClient with the network credentials of our user webClient.Credentials = CredentialCache.DefaultNetworkCredentials; //Download the byte array of the file byte[] data = webClient.DownloadData(insert_ attachment_url); //Dump the byte array in a memory stream because //we can write it to our attachment MemoryStream memoryStreamOfFile = new MemoryStream(data); //Add the attachment mailMessage.Attachments.Add(new System.Net.Mail.Attachment(memoryStreamOfFile, "LPO", ".png")); //Create the SMTP client object and send the message SmtpClient smtpClient = new SmtpClient(smtpServer); smtpClient.Send(mailMessage); } } } }