<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Sending mail through managed code</title><link>https://www.infopathdev.com:443/forums/thread/83122.aspx</link><pubDate>Sat, 29 Sep 2012 11:37:05 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:83122</guid><dc:creator>MADOURI</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/83122.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=83122</wfw:commentRss><description>&lt;p&gt;hi,&lt;/p&gt;&lt;p&gt;is there any way to send an email notification 4 months&amp;nbsp;after that the form is submitted....?&lt;/p&gt;&lt;p&gt;cdt.&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Sending mail through managed code</title><link>https://www.infopathdev.com:443/forums/thread/48292.aspx</link><pubDate>Tue, 27 Oct 2009 20:46:25 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:48292</guid><dc:creator>dggill</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/48292.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=48292</wfw:commentRss><description>&lt;p&gt;I have been trying to use the code written in the earlier part of this thread.&amp;nbsp; Following is my code which yields the error message below as well.&lt;/p&gt;
&lt;p&gt;function XDocument::OnSubmitRequest(eventObj)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;If the submit operation is successful, set eventObj.ReturnStatus = true;&lt;br /&gt;&amp;nbsp;MailMessage msgmail = new MailMessage();&lt;br /&gt;&amp;nbsp;msgmail.Body = &amp;quot;You have a new Best Practice form awaiting your Approval&amp;quot;;&lt;br /&gt;&amp;nbsp;msgmail.From = &amp;quot;xyz&lt;a href="mailto:xyz@xyz.com"&gt;@xyz.com&lt;/a&gt;&amp;quot;;&lt;br /&gt;&amp;nbsp;msgmail.To = &amp;quot;xyz.abc&lt;a href="mailto:xyz.abc@xyz.com"&gt;@xyz.com&lt;/a&gt;&amp;quot;;&lt;br /&gt;&amp;nbsp;msgmail.Subject = &amp;quot;Best Practice Alert&amp;quot;;&lt;br /&gt;&amp;nbsp;SmtpMail.SmtpServer = &amp;quot;xyzr.xyz.com&amp;quot;;&lt;br /&gt;&amp;nbsp;SmtpMail.Send(msgmail);&lt;/p&gt;&lt;font face="Helv" size="2"&gt;&lt;font face="Helv" size="2"&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Helv" size="2"&gt;&lt;font face="Helv" size="2"&gt;
&lt;p dir="ltr"&gt;I get the following message:&lt;/p&gt;
&lt;p dir="ltr"&gt;expected &amp;#39;;&amp;#39;&lt;/p&gt;
&lt;p dir="ltr"&gt;File: Script.js&lt;/p&gt;
&lt;p dir="ltr"&gt;Line:25&lt;/p&gt;
&lt;blockquote&gt;
&lt;p dir="ltr"&gt;MailMessage msgmail = new MailMessage( );&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;I am not a programer but nothing seems to work.&lt;/p&gt;
&lt;p dir="ltr"&gt;&amp;nbsp;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;</description></item><item><title>Re: Sending mail through managed code</title><link>https://www.infopathdev.com:443/forums/thread/34536.aspx</link><pubDate>Thu, 20 Nov 2008 01:18:42 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:34536</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/34536.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=34536</wfw:commentRss><description>&lt;p&gt;Nope, you never have the easy ones! From what I know and read in the documentation on MSDN, you will not be able to set just the &amp;#39;from&amp;#39; for an Email Submit connection. If you check &lt;a href="http://msdn.microsoft.com/en-us/library/microsoft.office.infopath.emailsubmitconnection_members(VS.80).aspx"&gt;this&lt;/a&gt; link, you&amp;#39;ll see that &amp;#39;from&amp;#39; isn&amp;#39;t in the listed members of the email connection class. &lt;/p&gt;
&lt;p&gt;Browsing some other posts on this forum, someone mentions that script in the IP2003 Issue Tracking sample form copies the form into the body, but the post that had that suggested they were just creating a text view, so not necessarily an exact replica...&lt;/p&gt;
&lt;p&gt;Also, &lt;a href="http://www.codeplex.com/SPDActivities"&gt;this&lt;/a&gt; link was mentioned in an earlier post today as a way to set the &amp;#39;from&amp;#39; field, you may want to check it out.&lt;/p&gt;
&lt;p&gt;Wish I had better news!&lt;/p&gt;</description></item><item><title>Re: Sending mail through managed code</title><link>https://www.infopathdev.com:443/forums/thread/34535.aspx</link><pubDate>Thu, 20 Nov 2008 00:20:34 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:34535</guid><dc:creator>BuildPro Guru</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/34535.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=34535</wfw:commentRss><description>&lt;p&gt;Hello Hilary!&amp;nbsp; It would appear as if you have your signature on every new skill that I try to learn here!&amp;nbsp; You are very busy!&lt;/p&gt;
&lt;p&gt;At any rate, is it possible to manipulate just the &amp;#39;from&amp;#39; on an email?&amp;nbsp; I have a rule to submit to database/sharepoint/email and it works swimmingly, but I would like to hard code the &amp;#39;from&amp;#39; information.&amp;nbsp; We have consolidated our customer care department into regional offices so we have a call center that answers calls for many cities.&amp;nbsp; The workflow is handled through IP (many thanks to you) and ultimately an email is generated to a trade partner requesting that warranty work be performed.&amp;nbsp; We have set up email accounts by division (-division&lt;a href="mailto:-divisionname-customercare@mycompany.com"&gt;name-customercare@mycompany.com&lt;/a&gt;) as well as a call center account (&lt;a href="mailto:customercare@mycompany.com"&gt;customercare@mycompany.com&lt;/a&gt;).&amp;nbsp; The folks working the call center have access to these accounts and they monitor all the emails with that regard.&amp;nbsp; The problem is that a particular individual will initiate the email, the trade partner will respond and instead of it coming to the community inbox, it goes back to that individual.&amp;nbsp; We need it to go back to the community inbox.&amp;nbsp; If I am unable to accomplish just hard coding the &amp;#39;from&amp;#39; and I&amp;nbsp;have to build the entire email sender, I will also&amp;nbsp;need to be able to embed the current view as HTML in the email.&lt;/p&gt;
&lt;p&gt;I never have the easy ones, do I?&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Sending mail through managed code</title><link>https://www.infopathdev.com:443/forums/thread/31663.aspx</link><pubDate>Mon, 25 Aug 2008 00:20:44 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:31663</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/31663.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=31663</wfw:commentRss><description>&lt;p&gt;Yes -- your form will need to be full trust. Try setting to full trust and see what happens.... Sadly, full trust forms have their own set of challenges, see &lt;a href="http://office.microsoft.com/en-us/infopath/HA101009571033.aspx"&gt;this&lt;/a&gt; article for more information.&lt;/p&gt;</description></item><item><title>Re: Sending mail through managed code</title><link>https://www.infopathdev.com:443/forums/thread/31662.aspx</link><pubDate>Sun, 24 Aug 2008 22:36:04 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:31662</guid><dc:creator>Michael Campbell</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/31662.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=31662</wfw:commentRss><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I used your email to code, as we use Lotus Notes and not Outlook. When I submit the InfoPath form, I get the following error message:&lt;/p&gt;
&lt;p&gt;&lt;/a&gt;System.Security.SecurityException&lt;br /&gt;Request for the permission of type &amp;#39;System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089&amp;#39; failed.&lt;br /&gt;&amp;nbsp;&amp;nbsp; at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark&amp;amp; stackMark, Boolean isPermSet)&lt;br /&gt;&amp;nbsp;&amp;nbsp; at System.Security.CodeAccessPermission.Demand()&lt;br /&gt;&amp;nbsp;&amp;nbsp; at System.Net.Mail.SmtpClient.Initialize()&lt;br /&gt;&amp;nbsp;&amp;nbsp; at System.Net.Mail.SmtpClient..ctor(String host)&lt;br /&gt;&amp;nbsp;&amp;nbsp; at SAMPLE___Email_via_Lotus_Notes.FormCode.LNEmail_Clicked(Object sender, ClickedEventArgs e)&lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)&lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Any suggestions on what may be causing this?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Michael&lt;br /&gt;&lt;/p&gt;</description></item><item><title>Re: Sending mail through managed code</title><link>https://www.infopathdev.com:443/forums/thread/31633.aspx</link><pubDate>Thu, 21 Aug 2008 22:15:33 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:31633</guid><dc:creator>Michael Campbell</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/31633.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=31633</wfw:commentRss><description>&lt;p&gt;Hilary&lt;/p&gt;
&lt;p&gt;Thank you so much....it&amp;#39;s all fine now. &lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Michael&lt;/p&gt;</description></item><item><title>Re: Sending mail through managed code</title><link>https://www.infopathdev.com:443/forums/thread/31612.aspx</link><pubDate>Thu, 21 Aug 2008 01:29:26 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:31612</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/31612.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=31612</wfw:commentRss><description>&lt;p&gt;Okay -- try this. Add at the top of your code windows (under the other &amp;quot;using&amp;quot; statements):&lt;/p&gt;
&lt;blockquote&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;using&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; System.Net.Mail;&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Now, instead of the above code, try this:&lt;/p&gt;
&lt;blockquote&gt;&lt;font size="2"&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;MailAddress&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; from = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;MailAddress&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;michael.campbell@carnivalaustralia.com&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;br /&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;MailAddress&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; to = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;MailAddress&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;lidia.cardillo@carnivalaustralia.com&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;br /&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;MailMessage&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; msgmail = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;MailMessage&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(from,to);&lt;br /&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;msgmail.Body = &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;You have a new form awaiting your Approval&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;br /&gt;msgmail.Subject = &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;Alert&amp;quot;&lt;/font&gt;&lt;/font&gt;;&lt;/font&gt;&lt;font size="2"&gt; &lt;br /&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;SmtpClient&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; client = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;SmtpClient&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;999999.carnivalaustralia.com&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;br /&gt;&lt;/font&gt;&lt;font size="2"&gt;client.Send(msgmail);&lt;/blockquote&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p&gt;Obviously, you need to change the to and from addresses, as well as the SmtpClient server address. The code compiles -- I haven&amp;#39;t tried actually running it, so let me know if you have trouble.&lt;/p&gt;</description></item><item><title>Re: Sending mail through managed code</title><link>https://www.infopathdev.com:443/forums/thread/31611.aspx</link><pubDate>Thu, 21 Aug 2008 00:26:23 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:31611</guid><dc:creator>Michael Campbell</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/31611.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=31611</wfw:commentRss><description>&lt;p&gt;Hilary&lt;/p&gt;
&lt;p&gt;You are dealing with a real novie here....so I need some more assistance.&lt;/p&gt;
&lt;p&gt;I changed from VB to C# and added the code, as follows:&lt;/p&gt;&lt;font size="2"&gt;MailMessage msgmail = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; MailMessage();&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;msgmail.Body = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;You have a new form awaiting your Approval&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/p&gt;msgmail.From = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;michael.campbell@carnivalaustralia.com&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;msgmail.To = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;lidia.cardillo@carnivalaustralia.com&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/p&gt;msgmail.Subject = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;Alert&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;SmtpMail.SmtpServer = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;999999.carnivalaustralia.com&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;//U r missing this line&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;SmtpMail.Send(msgmail);&lt;/p&gt;
&lt;p&gt;But when I debug, I get the following errors:&lt;/p&gt;
&lt;p&gt;&amp;quot;The type or namesopace name &amp;#39;MailMessage&amp;#39; could not be found (are you missing a using directive or an assembly reference&amp;#39;&lt;/p&gt;
&lt;p&gt;&amp;quot;The name &amp;#39;SmtpMail&amp;#39; does not exisst in the current context&amp;#39;&lt;/p&gt;&lt;/font&gt;</description></item><item><title>Re: Sending mail through managed code</title><link>https://www.infopathdev.com:443/forums/thread/31610.aspx</link><pubDate>Wed, 20 Aug 2008 23:14:01 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:31610</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/31610.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=31610</wfw:commentRss><description>&lt;p&gt;The code sample is in C#. It looks as if your form is set to use VB. VB declares variables differently (among other things, such as no end of line semicolon). You can either remove the code in your form and set the programming language to C# and try this sample again, or you can try to convert the sample to VB. At first glance, you should just be able to remove all semicolons, mark anything that starts with &amp;quot;//&amp;quot; with a single quote instead (different comment markers) and change this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;MailMessage msgmail = &lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; MailMessage();&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;to this:&lt;/p&gt;
&lt;blockquote&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;Dim&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; msgmail &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;As&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;New&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; MailMessage()&lt;/p&gt;&lt;/font&gt;&lt;/blockquote&gt;
&lt;p&gt;You&amp;#39;ll probably need to add an import statement as well like this:&lt;/p&gt;
&lt;blockquote&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;p&gt;Imports&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; System.Net.Mail&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;at the top of your code.&lt;/p&gt;</description></item><item><title>Re: Sending mail through managed code</title><link>https://www.infopathdev.com:443/forums/thread/31609.aspx</link><pubDate>Wed, 20 Aug 2008 22:31:02 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:31609</guid><dc:creator>Michael Campbell</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/31609.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=31609</wfw:commentRss><description>&lt;p&gt;Abhishek&lt;/p&gt;
&lt;p&gt;I am a real novice a coding, so can you assist me with this.&lt;/p&gt;
&lt;p&gt;I&amp;nbsp; have added a Button to my form, selected &lt;strong&gt;Rules and Custom Code&lt;/strong&gt; which have opened Visual Studio and I have added your code (as per example)&lt;/p&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Public&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Sub&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt; CTRL48_5_Clicked(&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;ByVal&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt; sender &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;As&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Object&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt;, &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;ByVal&lt;/font&gt;&lt;/font&gt;&lt;font color="#000000" size="2"&gt; e &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;As&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font color="#000000"&gt; ClickedEventArgs)&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;&amp;#39; Write your code here.&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;MailMessage msgmail = &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;new&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; MailMessage();&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;msgmail.Body = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;You have a new form awaiting your Approval&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/p&gt;msgmail.From = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;michael.campbell@carnivalaustralia.com&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;; &lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;msgmail.To = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;lidia.cardillo@carnivalaustralia.com&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;; &lt;/p&gt;msgmail.Subject = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;Alert&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;SmtpMail.SmtpServer = &lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;999999.carnivalaustralia.com&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; ;//U r missing this line&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 
&lt;p&gt;SmtpMail.Send(msgmail);&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;End&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Sub&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;End&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;Class&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt; 
&lt;p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;I get the following errors.&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#0000ff"&gt;Name &amp;#39;MailMessage&amp;#39; is not declaried&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#0000ff"&gt;Type &amp;#39;MailMessage&amp;#39; is not defined&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font color="#0000ff"&gt;&lt;/font&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Sending mail through managed code</title><link>https://www.infopathdev.com:443/forums/thread/10201.aspx</link><pubDate>Fri, 04 Aug 2006 07:51:21 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:10201</guid><dc:creator>Kalyan Gaddam</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/10201.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=10201</wfw:commentRss><description>Hello&lt;br /&gt;&lt;br /&gt;Read the link below&lt;br /&lt;a target="_blank" href=http://www.sharepointblogs.com/ssa/archive/2006/06/02/8029.aspx&gt;http://www.sharepointblogs.com/ssa/archive/2006/06/02/8029.aspx&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Hope it helps you</description></item><item><title>Re: Sending mail through managed code</title><link>https://www.infopathdev.com:443/forums/thread/10200.aspx</link><pubDate>Fri, 04 Aug 2006 06:22:25 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:10200</guid><dc:creator>Abhishek</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/10200.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=10200</wfw:commentRss><description>Hi Krishna Prasad,&lt;br /&gt;       This is the code I use to send mail.And it works fine.&lt;br /&gt;I dont use Microsoft Outlook.I use lotus notes.&lt;br /&gt;&lt;br /&gt;MailMessage msgmail = new MailMessage();&lt;br /&gt;msgmail.Body  = "You have a new form awaiting your Approval";&lt;br /&gt;msgmail.From  = "abcd@XYZ.com"; &lt;br /&gt;msgmail.To  = "abhishek.keshav@lntinfotech.com";  &lt;br /&gt;msgmail.Subject = "Alert";&lt;br /&gt;&lt;font color="red"&gt;SmtpMail.SmtpServer = "&amp;lt;Default SMTP Virtual Server Domain Name&amp;gt;" ;//U r missing this line&lt;/font id="red"&gt;&lt;br /&gt;SmtpMail.Send(msgmail);&lt;br /&gt;&lt;br /&gt;In ur system's IIS,u can find a Default SMTP Virtual server.Under that u have "Domains".Clicking that reveals ur domain name.&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;Abhishek</description></item><item><title>Sending mail through managed code</title><link>https://www.infopathdev.com:443/forums/thread/5756.aspx</link><pubDate>Fri, 04 Aug 2006 04:58:09 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:5756</guid><dc:creator>krishna.prasad</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/5756.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=5756</wfw:commentRss><description>Hi Friends,&lt;br /&gt;&lt;br /&gt;In my application i need to send email notification when the form is submitted. here i wrote code in the button click event. my problem is it is working when i tested in the server, but when the form is submitted in the client mechine means after publishint to sharepoint library it is promting with the error message.&lt;br /&gt;&lt;br /&gt;here is my code&lt;br /&gt;MailMessage mailMsg=new MailMessage();&lt;br /&gt;			thisXDocument.UI.Alert("Hi");&lt;br /&gt;			mailMsg.From = "spssrv2@lgcnsglobal.com";&lt;br /&gt;			//thisXDocument.UI.Alert(strReportingToMailId.text);&lt;br /&gt;			mailMsg.To = mail.text; //strReportingToMailId.text;&lt;br /&gt;			//mailMsg.Cc  =strInitiatedUserMailId.text;&lt;br /&gt;			mailMsg.Subject = "sending the mail when the button is clicked";&lt;br /&gt;			mailMsg.BodyFormat = MailFormat.Html;&lt;br /&gt;			//mailMsg.Body = nv.Body ;&lt;br /&gt;			SmtpMail.Send( mailMsg );&lt;br /&gt;&lt;br /&gt;            thisApplication.ActiveWindow.Close(true);&lt;br /&gt;&lt;br /&gt;the error message i am getting is &lt;br /&gt;&lt;br /&gt;Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.&lt;br /&gt;   at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)&lt;br /&gt;   at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)&lt;br /&gt;   at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException)&lt;br /&gt;   at System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs, PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Assembly asm, SecurityAction action)&lt;br /&gt;   at SendMail.SendMail.Button_OnClick(DocActionEvent e)&lt;br /&gt;   at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)&lt;br /&gt;&lt;br /&gt;Could any one please solve my problem?&lt;br /&gt;thanks in advance...&lt;br /&gt;</description></item></channel></rss>