+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / SMTP Setting Save & Test

SMTP Setting Save & Test

8 posts, 0 answered
  1. Nathan
    Nathan avatar
    7 posts
    Registered:
    25 Jun 2008
    04 Mar 2010
    Link to this post

    Dear Support.

    We're getting an error trying to save our SMTP Settings for our server.  I have included the stack trace below as well as the log file entry.  We are able to send from a mail script on our server that uses the same credentials.  Any ideas would be appreciated?

    Thanks for your help.   

    Server Error in '/' Application.
    --------------------------------------------------------------------------------

    An existing connection was forcibly closed by the remote host
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. 

    Stack Trace:

    [SocketException (0x2746): An existing connection was forcibly closed by the remote host]
       System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) +73
       System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +131

    [IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.]
       System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size) +313
       System.IO.StreamReader.ReadBuffer() +58
       System.IO.StreamReader.ReadToEnd() +106
       System.Web.Services.Protocols.RequestResponseUtils.ReadResponse(WebResponse response, Stream stream) +90
       System.Web.Services.Protocols.RequestResponseUtils.CreateResponseExceptionString(WebResponse response, Stream stream) +191
       System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) +431202
       System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters) +204
       Telerik.WebServices.DynamicProxy.MailingWebService.VerifySMTPSetting(String smtpHost, Int32 smtpPort, String smtpUsername, String smtpPassword, Boolean smtpSsL, String msgBody) +239

    [TargetInvocationException: Exception has been thrown by the target of an invocation.]
       System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +0
       System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner) +71
       System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +261
       System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +29
       System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +19
       Telerik.WebServices.DynamicProxy.WebServiceDynamicProxy.InvokeWebMethodCall(Boolean async) +269

    [WebMethodInvocationException: An error occured while calling the service.]
       Telerik.WebServices.DynamicProxy.WebServiceDynamicProxy.InvokeWebMethodCall(Boolean async) +667
       Telerik.WebServices.DynamicProxy.WebServiceDynamicProxy.InvokeWebMethodCall() +33
       Telerik.Notifications.Services.MailingServiceProxy.VerifySMTPSetting(String smtpHost, Int32 smtpPort, String smtpUsername, String smtpPassword, Boolean smtpSsL, String msgBody) +229
       Telerik.Notifications.Newsletters.WebControl.SMTPSettingControl.TestCurrentSettings() +498
       Telerik.Notifications.Newsletters.WebControl.SMTPSettingControl.SaveCurrentSetting() +48
       Telerik.Notifications.Newsletters.WebControl.SMTPSettingControl.button_Command(Object sender, CommandEventArgs e) +364
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +108
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

     

    --------------------------------------------------------------------------------
    Version Information: Microsoft .NET Framework Version:2.0.50727.4927; ASP.NET Version:2.0.50727.4927


    Log File
    ---------------------------------------------------------------------------------

    3/4/2010 2:50:11 PM [UNKNOWN]
    ************************************************************************************
    ID: 33f3081e-2912-44e1-89ea-ad571e9002cc; Code: 3005; Occurrence: 2; Sequence: 138
    ------------------------------------------------------------------------------------

    Application information:
     Machine name: NATHANA-WIN7PC
     OS Version: Microsoft Windows NT 6.1.7600.0
     Product Version: 3.7.2057.3
     Application Path: C:\Projects\SiteFinity\www\
     Debug: True

    Process information:
     Process ID: 6488
     Process Name: WebDev.WebServer

    Request information:
     Request URL: /Sitefinity/Admin/Modules.aspx?module=Newsletters
     Rewrite URL: http://localhost:52793/Sitefinity/Admin/Modules.aspx?module=Newsletters
     Url Referrer: http://localhost:52793/Sitefinity/Admin/Modules.aspx?module=Newsletters
     Is Authenticated: True
     Authentication Type: Forms
     User: NAbercrombie
     User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)
     User Address: 127.0.0.1

    Variables:
     RadControlRandomNumber: 0
     AspSessionIDManagerInitializeRequestCalled: True
     CmsHttpRequest: /Sitefinity/Admin/Modules.aspx?module=Newsletters

    - L0 -------------------------------------------------------------------------------

    Exception Type: Telerik.WebServices.DynamicProxy.WebMethodInvocationException

    Message: An error occured while calling the service.

    Source: Telerik.DynamicWebServices

    Stack Trace:
       at Telerik.WebServices.DynamicProxy.WebServiceDynamicProxy.InvokeWebMethodCall(Boolean async)
       at Telerik.WebServices.DynamicProxy.WebServiceDynamicProxy.InvokeWebMethodCall()
       at Telerik.Notifications.Services.MailingServiceProxy.VerifySMTPSetting(String smtpHost, Int32 smtpPort, String smtpUsername, String smtpPassword, Boolean smtpSsL, String msgBody)
       at Telerik.Notifications.Newsletters.WebControl.SMTPSettingControl.TestCurrentSettings()
       at Telerik.Notifications.Newsletters.WebControl.SMTPSettingControl.SaveCurrentSetting()
       at Telerik.Notifications.Newsletters.WebControl.SMTPSettingControl.button_Command(Object sender, CommandEventArgs e)
       at System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
       at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    ------------------------------------------------------------------------------------
    - L1 -------------------------------------------------------------------------------

    Exception Type: System.Reflection.TargetInvocationException

    Message: Exception has been thrown by the target of an invocation.

    Source: mscorlib

    Stack Trace:
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
       at Telerik.WebServices.DynamicProxy.WebServiceDynamicProxy.InvokeWebMethodCall(Boolean async)
    ------------------------------------------------------------------------------------
    - L2 -------------------------------------------------------------------------------

    Exception Type: System.IO.IOException

    Message: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

    Source: System

    Stack Trace:
       at System.Net.ConnectStream.Read(Byte[] buffer, Int32 offset, Int32 size)
       at System.IO.StreamReader.ReadBuffer()
       at System.IO.StreamReader.ReadToEnd()
       at System.Web.Services.Protocols.RequestResponseUtils.ReadResponse(WebResponse response, Stream stream)
       at System.Web.Services.Protocols.RequestResponseUtils.CreateResponseExceptionString(WebResponse response, Stream stream)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       at Telerik.WebServices.DynamicProxy.MailingWebService.VerifySMTPSetting(String smtpHost, Int32 smtpPort, String smtpUsername, String smtpPassword, Boolean smtpSsL, String msgBody)
    ------------------------------------------------------------------------------------
    - L3 -------------------------------------------------------------------------------

    Exception Type: System.Net.Sockets.SocketException

    Message: An existing connection was forcibly closed by the remote host

    Source: System

    Stack Trace:
       at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
       at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
    ------------------------------------------------------------------------------------

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    04 Mar 2010
    Link to this post
    Hello Nathan,

    Check whether you use some internal routing or ports that do not match the default one. Make sure that you are using the correct hosts and there are not any calls blocked by your firewall. When the Newsletters module is initializing, it's sending an anonymous web request to the mailing web service and it seems that this could not happen at your end. You can  Configure Network Tracing   and  Interpreting Network Tracing
    You could try using the code below to verify your SMTP settings. As you can see the code uses SmtpClient ASP.NET class

    public string VerifySMTPSetting  ( string smtpHost, int smtpPort, string smtpUsername,
                string smtpPassword, bool smtpSsL, string msgBody )
            {
                SmtpClient client = this.CreateSmtpClient ( smtpHost, smtpPort,
                    smtpUsername, smtpPassword, smtpSsL );
                try
                {
                    client.Send(ConfigHelper.Handler.ValidationEmailAddress, smtpUsername, "Verification email", msgBody);
                }
                catch ( Exception e )
                {
                    return "EXCEPTION";
                }
                return null;
            }
      
      
    private SmtpClient CreateSmtpClient ( string smtpHost, int smtpPort, string smtpUsername,
                string smtpPassword, bool smtpSsL )
            {
                SmtpClient client = new SmtpClient ( smtpHost, smtpPort );
                client.Credentials = new System.Net.NetworkCredential
                    ( smtpUsername, smtpPassword );
                client.EnableSsl = smtpSsL;
                return client;
            }

    Could you check whether you have the following web service under Sitefinity/Admin/Services
    MailingWebService.asmx and the folder and file have read permissions.

    <%@ WebService Language="C#" Class="Telerik.Notifications.Services.MailingWebService, Telerik.Notifications" %>


    It seems that the problem comes from the bool variable that checks the current setting by sending a verification mail. ASP.NET account needs -WebPermission and -SmtpPermission to work properly. Make sure that there are not any restrictions you may have related to the server trust level.

    Check whether you have a dll generated under Sitefinity/ServiceAssemblies. The Newsletters module generates a dll there that is later used. You could try the following as well

    1.Delete the assemble under Sitefinity/ServiceAssemblies
    2. Access the website backend. A new dll should be generated.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Nathan
    Nathan avatar
    7 posts
    Registered:
    25 Jun 2008
    05 Mar 2010
    Link to this post
    Hey Ivan.

    Thanks for your response and help.  We are getting a little closer.  I was able to create test smtp client and it fired off the emails from the data stored in the web.config.  Unfortunately, here's the latest log file error & error from the page:

    3/4/2010 7:31:05 PM [UNKNOWN]
    ************************************************************************************
    ID: 1397acac-6af7-4509-bdb3-1cc653656479; Code: 3005; Occurrence: 1; Sequence: 32
    ------------------------------------------------------------------------------------

    Application information:
     Machine name: DEDI537
     OS Version: Microsoft Windows NT 5.2.3790 Service Pack 2
     Product Version: 3.7.2057.3
     Application Path: d:\hosting\member\gaworkcomp\www2\
     Debug: True

    Process information:
     Process ID: 4112
     Process Name: w3wp

    Request information:
     Request URL: /Sitefinity/Admin/Modules.aspx?module=Newsletters
     Rewrite URL: http://www.rmitraining.net/Sitefinity/Admin/Modules.aspx?module=Newsletters
     Url Referrer: http://www.rmitraining.net/Sitefinity/Admin/Modules.aspx?module=Newsletters
     Is Authenticated: True
     Authentication Type: Forms
     User: NAbercrombie
     User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; Zune 4.0)
     User Address: 66.168.197.218

    Variables:
     RadControlRandomNumber: 0
     AspSessionIDManagerInitializeRequestCalled: True
     CmsHttpRequest: /Sitefinity/Admin/Modules.aspx?module=Newsletters

    - L0 -------------------------------------------------------------------------------

    Exception Type: System.Net.WebException

    Message: The request failed with the error message:
    --
    <html><head><title>Object moved</title></head><body>
    <h2>Object moved to <a href="%2fSitefinity%2fnopermissions.aspx">here</a>.</h2>
    </body></html>

    --.

    Source: Telerik.DynamicWebServices

    Stack Trace:
       at Telerik.WebServices.DynamicProxy.WebServiceDynamicProxy.InvokeWebMethodCall(Boolean async)
       at Telerik.WebServices.DynamicProxy.WebServiceDynamicProxy.InvokeWebMethodCall()
       at Telerik.Notifications.Services.MailingServiceProxy.VerifySMTPSetting(String smtpHost, Int32 smtpPort, String smtpUsername, String smtpPassword, Boolean smtpSsL, String msgBody)
       at Telerik.Notifications.Newsletters.WebControl.SMTPSettingControl.TestCurrentSettings()
       at Telerik.Notifications.Newsletters.WebControl.SMTPSettingControl.SaveCurrentSetting()
       at Telerik.Notifications.Newsletters.WebControl.SMTPSettingControl.button_Command(Object sender, CommandEventArgs e)
       at System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
       at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
       at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    ------------------------------------------------------------------------------------

     

    Page error:
    ------------------------------------------------------------------------------------
     

    Server Error in '/' Application.

    The request failed with the error message:
    --
    <html><head><title>Object moved</title></head><body>
    <h2>Object moved to <a href="%2fSitefinity%2fnopermissions.aspx">here</a>.</h2>
    </body></html>

    --.

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.Net.WebException: The request failed with the error message:
    --
    <html><head><title>Object moved</title></head><body>
    <h2>Object moved to <a href="%2fSitefinity%2fnopermissions.aspx">here</a>.</h2>
    </body></html>

    --.

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [WebException: The request failed with the error message:
    --
    <html><head><title>Object moved</title></head><body>
    <h2>Object moved to <a href="%2fSitefinity%2fnopermissions.aspx">here</a>.</h2>
    </body></html>
    
    --.]
       Telerik.WebServices.DynamicProxy.WebServiceDynamicProxy.InvokeWebMethodCall(Boolean async) +343
       Telerik.WebServices.DynamicProxy.WebServiceDynamicProxy.InvokeWebMethodCall() +7
       Telerik.Notifications.Services.MailingServiceProxy.VerifySMTPSetting(String smtpHost, Int32 smtpPort, String smtpUsername, String smtpPassword, Boolean smtpSsL, String msgBody) +153
       Telerik.Notifications.Newsletters.WebControl.SMTPSettingControl.TestCurrentSettings() +372
       Telerik.Notifications.Newsletters.WebControl.SMTPSettingControl.SaveCurrentSetting() +18
       Telerik.Notifications.Newsletters.WebControl.SMTPSettingControl.button_Command(Object sender, CommandEventArgs e) +292
       System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +108
       System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +135
       System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
       System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
       System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +175
       System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565
    


    Version Information: Microsoft .NET Framework Version:2.0.50727.3082; ASP.NET Version:2.0.50727.3082
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    05 Mar 2010
    Link to this post
    Hello Nathan,

    I am not able to reproduce this problem with the last official release. The problem you have is related to something that blocks the web service used to send newsletters or your setting just cannot be verified, because of some interaction between methods used in VerifySMTPSetting  and your ISP settings. Object moved means that once you click the button your header is altered and your are redirected. One possible reason for getting "object moved" is if you have some application inheritance or the host header is altered during the request.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Nathan
    Nathan avatar
    7 posts
    Registered:
    25 Jun 2008
    05 Mar 2010
    Link to this post
    Would it be possible to see the code for verifying the SMTP settings?  We have tested the settings in the web.config and are able to able to send emails from the server.  If we were able to walk through the code we might be able to narrow down the issue.

    Thanks again.
    Nathan
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    05 Mar 2010
    Link to this post
    Hi Nathan,

    Please use the code provided in the previous reply as suggested before.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  7. Nathan
    Nathan avatar
    7 posts
    Registered:
    25 Jun 2008
    05 Mar 2010
    Link to this post
    We did and the code worked just fine.  Does the webservice need special permissions?  The fact that the nopermissions.aspx file is being triggered looks like there's a security issue occurring.  Just thinking out loud.  Here's a copy of our test script we used to test the SMTP settings.  The Load SMTP button pulls the data from the web.config.

    <%

    @ Import Namespace="System.Net.Mail" %>

     

    <%

    @ Import Namespace="System.Configuration" %>

     

    <%

    @ Import Namespace="System.Web.Configuration" %>

     

    <%

    @ Import Namespace="System.Net.Configuration" %>

     

    <%

    @ Language="VB" trace="true" %>

     

    <

     

    html>

     

    <

     

    head>

     

    <

     

    title>SMTP Email Test</title>

     

    <

     

    script language="VB" runat="server">

     

     

    Sub Page_Load(Sender As Object, E As EventArgs)

     

     

     

    End Sub

     

     

     

    Public Sub Button1_Click(Sender as Object, E as EventArgs)

     

    Trace.Write(

    "Sending email...")

     

    SendEmail(txtTo.text, txtFrom.text, txtSubject.text, txtBody.text)

    Trace.Write(

    "Send complete @ " & Now.ToString())

     

     

    End Sub

     

     

     

    Public Sub Button2_Click(Sender as Object, E as EventArgs)

     

    Trace.Write(

    "Loading SMTP...")

     

    LoadSMTP()

    Trace.Write(

    "Load complete @ " & Now.ToString())

     

     

    End Sub

     

     

     

    Public Sub SendEmail(ByVal sTo as string, ByVal sFrom as string, ByVal sSubject as string, ByVal sBody as string)

     

     

    Dim mail As New System.Net.Mail.MailMessage()

     

     

    Dim smtp as System.Net.Mail.SmtpClient

     

     

     

    try

     

    smtp = CreateSmtpClient(txtAccount.text, txtPassword.text, txtPort.text, txtHost.text,

    false)

     

     

     

    With mail

     

    .To.Add(sTo)

    .From =

    New System.Net.Mail.MailAddress(sFrom)

     

    .Subject = sSubject

    .Body = sBody

     

    End With

     

     

    smtp.send(mail)

     

    catch ex as Exception

     

    lblMsg.Text = ex.toString()

     

    end try

     

     

     

    End Sub

     

     

     

    Public Function CreateSmtpClient(ByVal sAccount as string, ByVal sPassword as string, ByVal sPort as string, _

     

     

    ByVal sHost as string, ByVal bEnableSSL as boolean) as SmtpClient

     

     

     

    Dim sc as smtpClient = new SmtpClient(sHost)

     

     

    try

     

     

    With sc

     

    .Credentials =

    New System.Net.NetworkCredential(sAccount, sPassword)

     

    .Port = sPort

    .Host = sHost

    .EnableSSL = bEnableSSL

     

    End With

     

     

    catch ex as exception

     

    lblMsg.Text = ex.ToString()

     

    end try

     

     

     

    return sc

     

     

    End Function

     

     

     

    Public Sub LoadSMTP()

     

     

    Dim configurationFile As Configuration = WebConfigurationManager.OpenWebConfiguration("/web.config")

     

     

    Dim mailSettings As MailSettingsSectionGroup = configurationFile.GetSectionGroup("system.net/mailSettings")

     

     

     

    If Not mailSettings Is Nothing Then

     

     

    Dim port As Integer = mailSettings.Smtp.Network.Port

     

     

    Dim host As String = mailSettings.Smtp.Network.Host

     

     

    Dim password As String = mailSettings.Smtp.Network.Password

     

     

    Dim username As String = mailSettings.Smtp.Network.UserName

     

     

    txtAccount.text = username

    txtPassword.text = password

    txtPort.text = port

    txtHost.text = host

     

     

    End If

     

     

    End Sub

     

    </

     

    script>

     

     

     

    <style type="text/css">

     

     

    .style1

     

    {

     

    width: 100%;

     

    }

     

    </style>

     

     

    </

     

    head>

     

    <

     

    body>

     

     

     

    <form id="form1" runat="server">

     

     

    <table class="style1" width="100px">

     

     

    <tr>

     

     

    <td width="100px;">

     

    To:

    </td>

     

     

    <td>

     

     

    <asp:TextBox ID="txtTo" runat="server" Width="300px"></asp:TextBox>

     

     

    </td>

     

     

    </tr>

     

     

    <tr>

     

     

    <td width="100px;">

     

    From:

    </td>

     

     

    <td>

     

     

    <asp:TextBox ID="txtFrom" runat="server" Width="300px"></asp:TextBox>

     

     

    </td>

     

     

    </tr>

     

     

    <tr>

     

     

    <td width="100px;">

     

    Subject:

    </td>

     

     

    <td>

     

     

    <asp:TextBox ID="txtSubject" runat="server" Width="300px">Email Test</asp:TextBox>

     

     

    </td>

     

     

    </tr>

     

     

    <tr>

     

     

    <td width="100px;">

     

    Body:

    </td>

     

     

    <td>

     

     

    <asp:TextBox ID="txtBody" runat="server" Width="500px" Rows="10"

     

     

    TextMode="MultiLine">Testing email settings!</asp:TextBox>

     

     

    </td>

     

     

    </tr>

     

     

    <tr>

     

     

    <td width="100px;">

     

     

    &nbsp;</td>

     

     

    <td>

     

     

    &nbsp;</td>

     

     

    </tr>

     

     

    <tr>

     

     

    <td width="100px;">

     

    Account:

    </td>

     

     

    <td>

     

     

    <asp:TextBox ID="txtAccount" runat="server" Width="250"></asp:TextBox>

     

     

    <asp:TextBox ID="txtPassword" runat="server"></asp:TextBox>

     

     

    </td>

     

     

    </tr>

     

     

    <tr>

     

     

    <td width="100px;">

     

    Port:

    </td>

     

     

    <td>

     

     

    <asp:TextBox ID="txtPort" runat="server">25</asp:TextBox>

     

     

    </td>

     

     

    </tr>

     

     

    <tr>

     

     

    <td width="100px;">

     

    Host:

    </td>

     

     

    <td>

     

     

    <asp:TextBox ID="txtHost" runat="server" Width="300px"></asp:TextBox>

     

     

    </td>

     

     

    </tr>

     

     

    <tr>

     

     

    <td width="100px;">

     

    Enable SSL:

    </td>

     

     

    <td>

     

     

    <asp:CheckBox ID="cbEnableSSL" runat="server" />

     

     

    </td>

     

     

    </tr>

     

     

    <tr>

     

     

    <td width="100px;">

     

     

    &nbsp;</td>

     

     

    <td>

     

     

    &nbsp;</td>

     

     

    </tr>

     

     

    <tr>

     

     

    <td width="100px;">

     

     

    &nbsp;</td>

     

     

    <td>

     

     

    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Send Mail" />

     

     

    &nbsp;<asp:Button ID="Button2" runat="server" Text="Load SMTP Settings" OnClick="Button2_Click" />

     

     

    </td>

     

     

    </tr>

     

     

    </table>

     

     

    <asp:Label ID="lblMsg" runat="server"></asp:Label>

     

    </

     

    form>

     

     

    </

     

    body>

     

    </

     

    html>

     

  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    08 Mar 2010
    Link to this post
    Hello Nathan,

    InvokeWebMethodCall requires Reflection. Could you try to run the module in full trust and verify the SMTP settings through the module. The problem you have is not related to Newsletters module. You have some server settings that blocks the web service. It seems that the parameters you use for sending emails are correct, but the web method cannot be invoked. You can try the following method to see what will be returned

    MailingServiceProxy emailServices = new MailingServiceProxy();
          string host = "YOUR HOST";
          int port = 25;
          string uName = "YOUR USERNAME";
          string password = "YOUR PASSWORD";
          string body = "SomeBodyGoesHere";
          string result = emailServices.VerifySMTPSetting(host, port, uName, password, false, body);
          bool resultOk;
          if (string.IsNullOrEmpty(result))
              resultOk = false;
          resultOk = true;

    The object moved error could be thrown if MethodInfo class cannot be created  properly and Invoke method cannot be set.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Register for webinar
8 posts, 0 answered