{"id":79,"date":"2008-05-29T15:31:48","date_gmt":"2008-05-29T15:31:48","guid":{"rendered":"http:\/\/www.myfatblog.co.uk\/?p=79"},"modified":"2008-05-29T15:35:09","modified_gmt":"2008-05-29T15:35:09","slug":"using-the-undocumented-sputilitysendemail-method","status":"publish","type":"post","link":"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/05\/using-the-undocumented-sputilitysendemail-method\/","title":{"rendered":"Using the undocumented SPUtility.SendEmail method."},"content":{"rendered":"<p>As with a lot of the sharePoint API, the SPUtility class and more importantly the sendEMail method lacks a decent amount of documentation on its use.<\/p>\n<p>After a little bit of playing around with a console session, I&#8217;ve found what seems to be the best way to use this function. (For me at least.. feel free to disagree!!)<\/p>\n<p>Requires:<br \/>\n<code>using System.Collections.Specialized;<\/code><\/p>\n<p>For the purposes of my test code, I used a console sessions and wrapped the send email process inside two using statements to populate site and web with the test sharepoint site.<\/p>\n<p><code><br \/>\nStringDictionary headers = new StringDictionary();<br \/>\nheaders.add(\"to\",\"reginald@myfatblog.co.uk\");<br \/>\nheaders.add(\"cc\",\"thisiscopy@myfatblog.co.uk\");<br \/>\nheaders.add(\"bcc\",\"thisistheblindcopy@myfatblog.co.uk\");<br \/>\nheaders.add(\"from\",\"MySharePointEmail@myfatblog.co.uk\");<br \/>\nheaders.add(\"subject\",\"How to use SendEMail from SPUtility\");<br \/>\nheaders.add(\"content-type\",\"text\/html\"); \/\/This is the default type, so isn't neccessary.<\/p>\n<p>string bodyText =\"<html><body>This is the body of my email, in html format.<\/body><\/html>\";<\/p>\n<p>SPUtility.SendEmail(web, headers, bodyText);<br \/>\n<\/code><\/p>\n<p>The SendEmail method makes it very easy to pop emails out using your SharePoint sites current SMTP configuration, the only downside is that this does not allow you to use attachments. If you need to do this, then you&#8217;ll need to look down the .Net mail methods.. (I found a decent post on David Fekkes blog on how to do this using the .Net methods. I haven&#8217;t tried it yet, but it&#8217;s a good starting point. <a href=\"http:\/\/www.fekke.com\/blog\/index.cfm\/2008\/1\/21\/Sending-Email-with-Attachments-from-Sharepoint-Custom-Workflows\">Email with attachments from SharePoint code.<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As with a lot of the sharePoint API, the SPUtility class and more importantly the sendEMail method lacks a decent amount of documentation on its use. After a little bit of playing around with a console session, I&#8217;ve found what seems to be the best way to use this function. (For me at least.. feel &hellip; <\/p>\n<p><a class=\"more-link btn\" href=\"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/05\/using-the-undocumented-sputilitysendemail-method\/\">Continue reading<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[3,13,16,12],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Using the undocumented SPUtility.SendEmail method. - Blog of an overweight SharePoint addict<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/05\/using-the-undocumented-sputilitysendemail-method\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Using the undocumented SPUtility.SendEmail method. - Blog of an overweight SharePoint addict\" \/>\n<meta property=\"og:description\" content=\"As with a lot of the sharePoint API, the SPUtility class and more importantly the sendEMail method lacks a decent amount of documentation on its use. After a little bit of playing around with a console session, I&#8217;ve found what seems to be the best way to use this function. (For me at least.. feel &hellip; Continue reading\" \/>\n<meta property=\"og:url\" content=\"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/05\/using-the-undocumented-sputilitysendemail-method\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog of an overweight SharePoint addict\" \/>\n<meta property=\"article:published_time\" content=\"2008-05-29T15:31:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2008-05-29T15:35:09+00:00\" \/>\n<meta name=\"author\" content=\"Cimares\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@cimares\" \/>\n<meta name=\"twitter:site\" content=\"@cimares\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Cimares\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/05\/using-the-undocumented-sputilitysendemail-method\/\",\"url\":\"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/05\/using-the-undocumented-sputilitysendemail-method\/\",\"name\":\"Using the undocumented SPUtility.SendEmail method. - Blog of an overweight SharePoint addict\",\"isPartOf\":{\"@id\":\"http:\/\/www.myfatblog.co.uk\/#website\"},\"datePublished\":\"2008-05-29T15:31:48+00:00\",\"dateModified\":\"2008-05-29T15:35:09+00:00\",\"author\":{\"@id\":\"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/05\/using-the-undocumented-sputilitysendemail-method\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/#website\",\"url\":\"http:\/\/www.myfatblog.co.uk\/\",\"name\":\"Blog of an overweight SharePoint addict\",\"description\":\"The rantings of a (not so) food obsessed IT consultant!\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/www.myfatblog.co.uk\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6\",\"name\":\"Cimares\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/image\/\",\"url\":\"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg\",\"contentUrl\":\"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg\",\"caption\":\"Cimares\"},\"sameAs\":[\"http:\/\/www.myfatblog.co.uk\"],\"url\":\"http:\/\/www.myfatblog.co.uk\/index.php\/author\/reginald\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Using the undocumented SPUtility.SendEmail method. - Blog of an overweight SharePoint addict","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/05\/using-the-undocumented-sputilitysendemail-method\/","og_locale":"en_US","og_type":"article","og_title":"Using the undocumented SPUtility.SendEmail method. - Blog of an overweight SharePoint addict","og_description":"As with a lot of the sharePoint API, the SPUtility class and more importantly the sendEMail method lacks a decent amount of documentation on its use. After a little bit of playing around with a console session, I&#8217;ve found what seems to be the best way to use this function. (For me at least.. feel &hellip; Continue reading","og_url":"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/05\/using-the-undocumented-sputilitysendemail-method\/","og_site_name":"Blog of an overweight SharePoint addict","article_published_time":"2008-05-29T15:31:48+00:00","article_modified_time":"2008-05-29T15:35:09+00:00","author":"Cimares","twitter_card":"summary_large_image","twitter_creator":"@cimares","twitter_site":"@cimares","twitter_misc":{"Written by":"Cimares","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/05\/using-the-undocumented-sputilitysendemail-method\/","url":"http:\/\/www.myfatblog.co.uk\/index.php\/2008\/05\/using-the-undocumented-sputilitysendemail-method\/","name":"Using the undocumented SPUtility.SendEmail method. - Blog of an overweight SharePoint addict","isPartOf":{"@id":"http:\/\/www.myfatblog.co.uk\/#website"},"datePublished":"2008-05-29T15:31:48+00:00","dateModified":"2008-05-29T15:35:09+00:00","author":{"@id":"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["http:\/\/www.myfatblog.co.uk\/index.php\/2008\/05\/using-the-undocumented-sputilitysendemail-method\/"]}]},{"@type":"WebSite","@id":"http:\/\/www.myfatblog.co.uk\/#website","url":"http:\/\/www.myfatblog.co.uk\/","name":"Blog of an overweight SharePoint addict","description":"The rantings of a (not so) food obsessed IT consultant!","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/www.myfatblog.co.uk\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/55ae8f6885bb5b8390dad001f3da83c6","name":"Cimares","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/www.myfatblog.co.uk\/#\/schema\/person\/image\/","url":"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg","contentUrl":"http:\/\/www.myfatblog.co.uk\/images\/BlogImages\/About_D057\/TopOfTheWorld.jpg","caption":"Cimares"},"sameAs":["http:\/\/www.myfatblog.co.uk"],"url":"http:\/\/www.myfatblog.co.uk\/index.php\/author\/reginald\/"}]}},"_links":{"self":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/79"}],"collection":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/comments?post=79"}],"version-history":[{"count":0,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/posts\/79\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/media?parent=79"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/categories?post=79"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.myfatblog.co.uk\/index.php\/wp-json\/wp\/v2\/tags?post=79"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}