Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Create the Outlook application.
- Outlook.Application oApp = new Outlook.Application();
- // Create a new mail item.
- Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
- // Set HTMLBody.
- //add the body of the email
- oMsg.HTMLBody = "Hello, Jawed your message body will go here!!";
- //Add an attachment.
- String sDisplayName = "MyAttachment";
- int iPosition = (int)oMsg.Body.Length + 1;
- int iAttachType = (int)Outlook.OlAttachmentType.olByValue;
- //now attached the file
- Outlook.Attachment oAttach = oMsg.Attachments.Add(@"C:\fileName.jpg", iAttachType, iPosition, sDisplayName);
- //Subject line
- oMsg.Subject = "Your Subject will go here.";
- // Add a recipient.
- Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
- // Change the recipient in the next line if necessary.
- Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add("lukasz.ogan@gmail.com");
- oRecip.Resolve();
- // Send.
- oMsg.Send();
- // Clean up.
- oRecip = null;
- oRecips = null;
- oMsg = null;
- oApp = null;
Add Comment
Please, Sign In to add comment