Hi;
I'm trying send a mail from my infopath form with button action... It seems the code is very easy but when I debug I got and error message at the end of code block SmtpMail.Send(mail);
Error or Warning Message is :
System.Web.HttpException was unhandled by user code
Message="The transport failed to connect to the server.\r\n"
Source="System.Web"
ErrorCode=-2147467259
StackTrace:
at System.Web.Mail.SmtpMail.LateBoundAccessHelper.CallMethod(Object obj, String methodName, Object[] args)
at System.Web.Mail.SmtpMail.CdoSysHelper.Send(MailMessage message)
at System.Web.Mail.SmtpMail.Send(MailMessage message)
at Aktiviteler.FormCode.CTRL68_5_Clicked(Object sender, ClickedEventArgs e) in D:\My Documents\InfoPath Projects\Aktiviteler5\FormCode.cs:line 45
at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)
Here's my code :
using Microsoft.Office.InfoPath;
using System;
using System.Xml;
using System.Xml.XPath;
using System.Web.Mail;
using Microsoft.Office.Interop.Outlook;
namespace Aktiviteler
{
public partial class FormCode
{
public void InternalStartup()
{
((ButtonEvent)EventManager.ControlEvents["CTRL68_5"]).Clicked += new ClickedEventHandler(CTRL68_5_Clicked);
}
public void CTRL68_5_Clicked(object sender, ClickedEventArgs e)
{
MailMessage mail = new MailMessage();
mail.To = "[email protected]";
mail.From = "[email protected]";
mail.Subject = "this is a test email.";
mail.Body = "this is my test email body";
SmtpMail.SmtpServer = "bhldscas1.internal.borusan.com";
SmtpMail.Send(mail);
}
}
}
Where I make a mistake? And could help me about the solution...Thanks