Guest User

Untitled

a guest
Apr 20th, 2018
933
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. // Create the Outlook application.
  2. Outlook.Application oApp = new Outlook.Application();
  3. // Create a new mail item.
  4. Outlook.MailItem oMsg = (Outlook.MailItem)oApp.CreateItem(Outlook.OlItemType.olMailItem);
  5. // Set HTMLBody.
  6. //add the body of the email
  7. oMsg.HTMLBody = "Hello, Jawed your message body will go here!!";
  8. //Add an attachment.
  9. String sDisplayName = "MyAttachment";
  10. int iPosition = (int)oMsg.Body.Length + 1;
  11. int iAttachType = (int)Outlook.OlAttachmentType.olByValue;
  12. //now attached the file
  13. Outlook.Attachment oAttach = oMsg.Attachments.Add(@"C:\fileName.jpg", iAttachType, iPosition, sDisplayName);
  14. //Subject line
  15. oMsg.Subject = "Your Subject will go here.";
  16. // Add a recipient.
  17. Outlook.Recipients oRecips = (Outlook.Recipients)oMsg.Recipients;
  18. // Change the recipient in the next line if necessary.
  19. Outlook.Recipient oRecip = (Outlook.Recipient)oRecips.Add("lukasz.ogan@gmail.com");
  20. oRecip.Resolve();
  21. // Send.
  22. oMsg.Send();
  23. // Clean up.
  24. oRecip = null;
  25. oRecips = null;
  26. oMsg = null;
  27. oApp = null;
Add Comment
Please, Sign In to add comment