Showing posts with label email. Show all posts
Showing posts with label email. Show all posts

Wednesday, March 28, 2012

Troubble with links in emails

I'm having trouble with links in emails which are sent from my webapp. I'm using System.Net.Mail.SmtpClient and sending mails as plain text. My email body contains a link e.g.http://www.blabla.com/Page.aspx. Some times the dot between blabla and com disappears when the recipient gets the mail.
I was sure this was an issue with the mail client, but apparently many of our customers are experiencing the same problem. I haven't been able to reproduce this problem myself because all my email clients display the links properly, but I have had some of our clients forward the mails to me, and the dot is actually missing. (http://www.blablacom/Page.aspx).
Have any of you guys seen this problem before? And how can I solve it?Are you still using the Beta version??
Yes, this is beta 2. I haven't been able to test it on the final version yet, because I can't reproduce the problem myself and we haven't shipped the new version to our customers yet.
Do you think it will work differently in the final version?
This is an issue that I haven't heard of earlier. I suggest you download the RTM of the .Net Framework and install it (remember to uninstall any beta version before installing if you intend to do this on the same machine). If your problem remains, I suggest you check the original data and code for string manipulation methods which may cause dots to disappear.
We uninstalled Beta 2 and installed RTM. This solved the problem without any changes to the code.

Saturday, March 24, 2012

Trouble sending email with ASP.NET 2.0

I have an ASP.NET 2.0 application that is supposed to send an email after a
certain form is submitted. When it tries to send the email, I receive the
following error:
Transaction failed. The server response was: njsokalski@dotnet.itags.org.hotmail.com:
Recipient address rejected: Access denied
(in the error message, the part with the email address was displayed as
<myemailaddress>, but you will probably see a link because our news viewers
think they know what we want). I know that the address is correct, so what
is it that the server didn't like about it? Is it saying I don't have
permission to use the SMTP server (I was pretty sure I was, but this is the
first time I am sending email from this server)? Is there something wrong
with my code? Any help would be appreciated. Thanks.
--
Nathan Sokalski
njsokalski@dotnet.itags.org.hotmail.com
http://www.nathansokalski.com/On Fri, 5 Jan 2007 03:55:44 -0500, "Nathan Sokalski"
<njsokalski@.hotmail.com> wrote:

> Is there something wrong
>with my code? Any help would be appreciated. Thanks.
You didn't provide your code, so it is hard to tell.
However, this works for me:
Try
Dim mail As New Mail.MailMessage()
mail.From = New Mail.MailAddress("mail@.mail.somewhere",
"Subject")
mail.To.Add("another@.mail.somewhere")
mail.Subject = "Subject"
mail.Body = "Body"
Dim smtp As New Mail.SmtpClient("mail.planprojekt.dk")
smtp.Credentials = New
NetworkCredential("mail@.mail.somewhere", "password")
smtp.Send(mail)
bEmailSent = True
Catch ex As Exception
Exit Sub
End Try
/Snedker
If you are using the machine's local SMTP Service,
you may need to add a Smarthost or domains (e.g., "*.com", "*.net")
so that email sent through it is allowed to be sent out or relayed.
Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"Nathan Sokalski" wrote:

> I have an ASP.NET 2.0 application that is supposed to send an email after
a
> certain form is submitted. When it tries to send the email, I receive the
> following error:
>
> Transaction failed. The server response was: njsokalski@.hotmail.com:
> Recipient address rejected: Access denied
>
> (in the error message, the part with the email address was displayed as
> <myemailaddress>, but you will probably see a link because our news viewer
s
> think they know what we want). I know that the address is correct, so what
> is it that the server didn't like about it? Is it saying I don't have
> permission to use the SMTP server (I was pretty sure I was, but this is th
e
> first time I am sending email from this server)? Is there something wrong
> with my code? Any help would be appreciated. Thanks.
> --
> Nathan Sokalski
> njsokalski@.hotmail.com
> http://www.nathansokalski.com/
>
>
The code I am using is as follows:
Private Sub SendEmailNotification()
Dim confsender As New
SmtpClient(System.Configuration.ConfigurationManager.AppSettings("smtpserver
"))
Dim confirmation As New MailMessage()
confirmation.IsBodyHtml = False
confirmation.From = New MailAddress("fromaddress@.mydomain.com")
confirmation.To.Add("njsokalski@.hotmail.com")
confirmation.Subject = "My Subject"
confirmation.Body = "My Body"
confsender.Send(confirmation)
End Sub
Thanks.
--
Nathan Sokalski
njsokalski@.hotmail.com
http://www.nathansokalski.com/
"Morten Snedker" <morten_spammenot_ATdbconsult.dk> wrote in message
news:2p6sp2dqb6qkfg0j60i3gt12iqvhdgcj70@.
4ax.com...
> On Fri, 5 Jan 2007 03:55:44 -0500, "Nathan Sokalski"
> <njsokalski@.hotmail.com> wrote:
>
> You didn't provide your code, so it is hard to tell.
> However, this works for me:
> Try
> Dim mail As New Mail.MailMessage()
> mail.From = New Mail.MailAddress("mail@.mail.somewhere",
> "Subject")
> mail.To.Add("another@.mail.somewhere")
> mail.Subject = "Subject"
> mail.Body = "Body"
> Dim smtp As New Mail.SmtpClient("mail.planprojekt.dk")
> smtp.Credentials = New
> NetworkCredential("mail@.mail.somewhere", "password")
> smtp.Send(mail)
> bEmailSent = True
> Catch ex As Exception
> Exit Sub
> End Try
>
> /Snedker

Trouble sending email with ASP.NET 2.0

I have an ASP.NET 2.0 application that is supposed to send an email after a
certain form is submitted. When it tries to send the email, I receive the
following error:

Transaction failed. The server response was: njsokalski@dotnet.itags.org.hotmail.com:
Recipient address rejected: Access denied

(in the error message, the part with the email address was displayed as
<myemailaddress>, but you will probably see a link because our news viewers
think they know what we want). I know that the address is correct, so what
is it that the server didn't like about it? Is it saying I don't have
permission to use the SMTP server (I was pretty sure I was, but this is the
first time I am sending email from this server)? Is there something wrong
with my code? Any help would be appreciated. Thanks.
--
Nathan Sokalski
njsokalski@dotnet.itags.org.hotmail.com
http://www.nathansokalski.com/On Fri, 5 Jan 2007 03:55:44 -0500, "Nathan Sokalski"
<njsokalski@.hotmail.comwrote:

Quote:

Originally Posted by

Is there something wrong
>with my code? Any help would be appreciated. Thanks.


You didn't provide your code, so it is hard to tell.

However, this works for me:

Try
Dim mail As New Mail.MailMessage()

mail.From = New Mail.MailAddress("mail@.mail.somewhere",
"Subject")
mail.To.Add("another@.mail.somewhere")

mail.Subject = "Subject"
mail.Body = "Body"

Dim smtp As New Mail.SmtpClient("mail.planprojekt.dk")
smtp.Credentials = New
NetworkCredential("mail@.mail.somewhere", "password")
smtp.Send(mail)

bEmailSent = True
Catch ex As Exception
Exit Sub
End Try

/Snedker
The code I am using is as follows:

Private Sub SendEmailNotification()
Dim confsender As New
SmtpClient(System.Configuration.ConfigurationManag er.AppSettings("smtpserver"))
Dim confirmation As New MailMessage()
confirmation.IsBodyHtml = False
confirmation.From = New MailAddress("fromaddress@.mydomain.com")
confirmation.To.Add("njsokalski@.hotmail.com")
confirmation.Subject = "My Subject"
confirmation.Body = "My Body"

confsender.Send(confirmation)
End Sub

Thanks.
--
Nathan Sokalski
njsokalski@.hotmail.com
http://www.nathansokalski.com/
"Morten Snedker" <morten_spammenot_ATdbconsult.dkwrote in message
news:2p6sp2dqb6qkfg0j60i3gt12iqvhdgcj70@.4ax.com...

Quote:

Originally Posted by

On Fri, 5 Jan 2007 03:55:44 -0500, "Nathan Sokalski"
<njsokalski@.hotmail.comwrote:
>

Quote:

Originally Posted by

>Is there something wrong
>>with my code? Any help would be appreciated. Thanks.


>
You didn't provide your code, so it is hard to tell.
>
However, this works for me:
>
Try
Dim mail As New Mail.MailMessage()
>
mail.From = New Mail.MailAddress("mail@.mail.somewhere",
"Subject")
mail.To.Add("another@.mail.somewhere")
>
mail.Subject = "Subject"
mail.Body = "Body"
>
Dim smtp As New Mail.SmtpClient("mail.planprojekt.dk")
smtp.Credentials = New
NetworkCredential("mail@.mail.somewhere", "password")
smtp.Send(mail)
>
bEmailSent = True
Catch ex As Exception
Exit Sub
End Try
>
>
/Snedker

Trouble setting up .NET to email

I read the FAQ on setting up the Virtual Email Server, but I am still having trouble getting .NET to send an email:

The error I'm getting is "Could not access 'CDO.Message' object."

Now, I'm not sure, but could it have something to do with the fact that my computer is hooked up to a base station (router) that may have the port blocked?

If so, do you know which port/s I should try forwarding?

I could have just F'ed something else up along the way, anyways, if anyone has any ideas, I'd love to hear them.

Thanks in advance,

GrierThis is probably a problem with the security settings in the IIS SMTP service. Have you checked the SMPTSVC log or the Event Viewer for any messages?
I believe 25 is the default port for SMTP. Are you specifying "localhost" as your SmtpMail.SmtpServer?
You are correct. 25 is the default SMTP port.
Could you post some of your code so we can decipher what is going on?
Thanks for the response!!! I have not checked the logs, (not sure if I know how...)


void OnSend (Object sender, EventArgs e)
{
MailMessage message = new MailMessage();

message.From = "gallen@.slantmedia.net";
message.To = "gallen@.slantmedia.net";
message.Subject = "Validate This Message";
message.Body = Body.Text;
SmtpMail.SmtpServer = "localhost";

try
{
SmtpMail.Send (message);
Label1.Text = "Message Sent!";
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
}

there is the code I've been using, thanks for taking a look!!!!

G
There are two places to check for logs. The first is the Windows Event Viewer. This can be found under the Administrative Tools. Look in the System log for any events with "SMTPSVC" as the source.

Second you can check the logfile that is generated by the SMTP service. This can be found in %windir%\system32\logfiles\smtpsvc1 by default. This may not provide as much information if you are not very familiar with SMTP.

Your code looks pretty standard so I don't think that the problem rests there. The next thing to look at is the setup for your SMTP service. Normally SMTP servers only allow messages which are addressed to a domain that is hosted by that server. Getting the SMTP server to accept a message from you (or from ASP.NET) and forward on to another mail server is called relaying. You have to configure your server to allow this.

Go to Administrative Tools > Internet Information Services > Default SMTP Virtual Server > (right click) > Properties > Access Tab > Relay. This will open the Relay Restrictions window. Select "only the list below" and then add 127.0.0.1 as an allowed computer. After you have completed this configuration, try running through your code again.

Trouble testing with ACT and ASP.NET

(sorry, I am just having trouble getting my Universal MSDN subscription news
group email address hooked up so MSFT responds so I am reposting hoping it i
s now setup right)
Here is our scenario:
.asmx web service on server 1 (Windows 2003)
on server 2 (Windows 2000), we run ACT with 100 concurrent users calling an
ASP that uses a COM+ VB6 DLL SOAPing to .asmx file. We read 100 concurrent r
equests in ASP.NET Requests Current on server 1.
on server 2, we run a .NET Console app that SOAPs to the .asmx file. We have
it looping continuously making the same call. We open about twelve instance
s of the console. We read a varying number of concurrent requests but we see
values in the 20's.
on server 2, we run a .aspx web form that SOAPs to the .asmx file. We run AC
T with 100 concurrent users. We consistently see only 4-5 concurrent request
s on server 1.
Is there some configuration of web or machine.config we are missing?
Thanks!This may help
http://msdn.microsoft.com/library/d...ice07222003.asp
Michael
This posting is provided "AS IS" with no warranties, and confers no rights.
<fm@.newsgroups.nospam> wrote in message
news:C670EE88-C76B-4661-B8B5-5C6C8A2AF2FE@.microsoft.com...
> (sorry, I am just having trouble getting my Universal MSDN subscription
> newsgroup email address hooked up so MSFT responds so I am reposting
> hoping it is now setup right)
> Here is our scenario:
> .asmx web service on server 1 (Windows 2003)
> on server 2 (Windows 2000), we run ACT with 100 concurrent users calling
> an ASP that uses a COM+ VB6 DLL SOAPing to .asmx file. We read 100
> concurrent requests in ASP.NET Requests Current on server 1.
> on server 2, we run a .NET Console app that SOAPs to the .asmx file. We
> have it looping continuously making the same call. We open about twelve
> instances of the console. We read a varying number of concurrent requests
> but we see values in the 20's.
> on server 2, we run a .aspx web form that SOAPs to the .asmx file. We run
> ACT with 100 concurrent users. We consistently see only 4-5 concurrent
> requests on server 1.
> Is there some configuration of web or machine.config we are missing?
> Thanks!
>
see answer to your previous post
<fm@.newsgroups.nospam> wrote in message
news:C670EE88-C76B-4661-B8B5-5C6C8A2AF2FE@.microsoft.com...
> (sorry, I am just having trouble getting my Universal MSDN subscription
newsgroup email address hooked up so MSFT responds so I am reposting hoping
it is now setup right)
> Here is our scenario:
> .asmx web service on server 1 (Windows 2003)
> on server 2 (Windows 2000), we run ACT with 100 concurrent users calling
an ASP that uses a COM+ VB6 DLL SOAPing to .asmx file. We read 100
concurrent requests in ASP.NET Requests Current on server 1.
> on server 2, we run a .NET Console app that SOAPs to the .asmx file. We
have it looping continuously making the same call. We open about twelve
instances of the console. We read a varying number of concurrent requests
but we see values in the 20's.
> on server 2, we run a .aspx web form that SOAPs to the .asmx file. We run
ACT with 100 concurrent users. We consistently see only 4-5 concurrent
requests on server 1.
> Is there some configuration of web or machine.config we are missing?
> Thanks!
>
This article did help. I put the following into Web.Config of the client ASP
X
that calls the Web Service:
<system.net>
<connectionManagement>
<add address="*" maxconnection="40" />
</connectionManagement>
</system.net>
<system.web>
We modified this number and did a few tests. We tried 60, 40 and 20. All
were better then the default of 2. 40-20 seemed the best range. We checked
time to first byte, current ASP.NET requests and server CPU usage.
We went looking for why this 2 connection limit and we found this blog:
http://odetocode.com/Blogs/scott/ar...06/08/272.aspx. So I think we
feel very comfortable in changing this value.
We may also look at calling the web service asynchronously as the article
you provided suggests.
Thanks for the help.
"Michael O'Donovan [MSFT]" wrote:

> This may help
> http://msdn.microsoft.com/library/d...ice07222003.asp
> Michael
> --
> This posting is provided "AS IS" with no warranties, and confers no rights
.
> <fm@.newsgroups.nospam> wrote in message
> news:C670EE88-C76B-4661-B8B5-5C6C8A2AF2FE@.microsoft.com...
>
>

Trouble understanding relationship between .Net SMTP and IIS SMTP

I have read some FAQs on System.net.mail but I have not seen a clear explaination of how to set up the email to hit a remote server

We use Godaddy.com for our Email so I want to log on and delivery my outgoing email to them.

Both IIS and .Net allow me to specify server settings - so how should I do this?

1. Tell .net in web.config that my server is "localhost" and then configure IIS SMPT to log onto Godaddy?

2. Tell .Net in Web.Config that my server is the Godaddy server and log on directly from there, bypassing IIS?

IIS SMPT is called a "virtual server" - does that mean it needs to hit a "real" server or can it be used to send real email directly?

if #1 above, should I use the IIS pickup directory or not?

Thanks

Bill

Remove SMTP from IIS. You don't need it for system.net.mail, you just need a SMTP server somewhere that you can send your mail through.

Now, configure system.net.mail, in web.config or elsewhere, to send through the GoDaddy server with the login/password fo your account. Seewww.systemnetmail.com for help on the coding.

Jeff


Thanks,

Perhaps that first sentence should be in the Faq's since I read plenty about using Localhost or 127.0.0.1 which suggesed to me that IIS was necessary.

Bill


Back in the NT4 days with CDONTS, a local SMTP server was required. IIS ships with a SMTP server, so it's always a possibility. But the only real requirement is a SMTP server somewhere that can be reached by the code. Of course, tha can still be Localhost, though if you're on a broadband connection or a dynamic IP many SMTP servers will refuse transactions with you, since the "hobbyist" servers are more likely to be compromised and sending SPAM.

Jeff

Trouble w sending email

Hi,
Trying to send an email with .net from my home computer.
A very simple one...
***************************
<%@dotnet.itags.org. Page Language="VB" %>
<%@dotnet.itags.org. Import Namespace="System.Web.Mail" %>
<script runat="server">
Sub Button1_Click(sender As Object, e As EventArgs)
SmtpMail.Send( _
"kenneth.philp@dotnet.itags.org.sverige.nu", _
"kenneth.philp@dotnet.itags.org.sverige.nu", _
"Testing mail", _
"Just sending a test message!")
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server" ID="Form1">
<asp:Button id="Button1" onclick="Button1_Click" runat="server"
Text="Button"></asp:Button>
</form>
</body>
</html>
**********************
I'm getting this error message
********************************
Configurationvalue "SendUsing" not valid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information abou
t
the error and where it originated in the code.
Exception Details: System.Runtime.InteropServices.COMException:
Configurationvalue "SendUsing" not valid.
Source Error:
Line 4:
Line 5: Sub Button1_Click(sender As Object, e As EventArgs)
Line 6: SmtpMail.Send( _
Line 7: "kenneth.philp@dotnet.itags.org.sverige.nu", _
Line 8: "kenneth.philp@dotnet.itags.org.sverige.nu", _
*********************************
I've checked that smtp services are on
What does "Sendusing" indicate?
Cheers.
KennethThe problem might be cos you're not specifying the SMTP server to send
through.
"Kenneth P" <KennethP@.discussions.microsoft.com> wrote in message
news:E07039CF-3FD5-49CD-BF51-EE5BF7A5BFF6@.microsoft.com...
> Hi,
> Trying to send an email with .net from my home computer.
> A very simple one...
> ***************************
> <%@. Page Language="VB" %>
> <%@. Import Namespace="System.Web.Mail" %>
> <script runat="server">
> Sub Button1_Click(sender As Object, e As EventArgs)
> SmtpMail.Send( _
> "kenneth.philp@.sverige.nu", _
> "kenneth.philp@.sverige.nu", _
> "Testing mail", _
> "Just sending a test message!")
> End Sub
> </script>
> <html>
> <head>
> </head>
> <body>
> <form runat="server" ID="Form1">
> <asp:Button id="Button1" onclick="Button1_Click" runat="server"
> Text="Button"></asp:Button>
> </form>
> </body>
> </html>
> **********************
> I'm getting this error message
> ********************************
> Configurationvalue "SendUsing" not valid.
> 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.Runtime.InteropServices.COMException:
> Configurationvalue "SendUsing" not valid.
> Source Error:
>
> Line 4:
> Line 5: Sub Button1_Click(sender As Object, e As EventArgs)
> Line 6: SmtpMail.Send( _
> Line 7: "kenneth.philp@.sverige.nu", _
> Line 8: "kenneth.philp@.sverige.nu", _
> *********************************
> I've checked that smtp services are on
> What does "Sendusing" indicate?
> Cheers.
> Kenneth

Trouble w sending email

Hi,

Trying to send an email with .net from my home computer.

A very simple one...

***************************
<%@dotnet.itags.org. Page Language="VB" %>
<%@dotnet.itags.org. Import Namespace="System.Web.Mail" %>
<script runat="server"
Sub Button1_Click(sender As Object, e As EventArgs)
SmtpMail.Send( _
"kenneth.philp@dotnet.itags.org.sverige.nu", _
"kenneth.philp@dotnet.itags.org.sverige.nu", _
"Testing mail", _
"Just sending a test message!")
End Sub

</script>
<html>
<head>
</head>
<body>
<form runat="server" ID="Form1">
<asp:Button id="Button1" onclick="Button1_Click" runat="server"
Text="Button"></asp:Button>
</form>
</body>
</html>
**********************

I'm getting this error message

********************************
Configurationvalue "SendUsing" not valid.
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.Runtime.InteropServices.COMException:
Configurationvalue "SendUsing" not valid.

Source Error:

Line 4:
Line 5: Sub Button1_Click(sender As Object, e As EventArgs)
Line 6: SmtpMail.Send( _
Line 7: "kenneth.philp@dotnet.itags.org.sverige.nu", _
Line 8: "kenneth.philp@dotnet.itags.org.sverige.nu", _

*********************************

I've checked that smtp services are on

What does "Sendusing" indicate?

Cheers.

KennethThe problem might be cos you're not specifying the SMTP server to send
through.

"Kenneth P" <KennethP@.discussions.microsoft.com> wrote in message
news:E07039CF-3FD5-49CD-BF51-EE5BF7A5BFF6@.microsoft.com...
> Hi,
> Trying to send an email with .net from my home computer.
> A very simple one...
> ***************************
> <%@. Page Language="VB" %>
> <%@. Import Namespace="System.Web.Mail" %>
> <script runat="server">
> Sub Button1_Click(sender As Object, e As EventArgs)
> SmtpMail.Send( _
> "kenneth.philp@.sverige.nu", _
> "kenneth.philp@.sverige.nu", _
> "Testing mail", _
> "Just sending a test message!")
> End Sub
> </script>
> <html>
> <head>
> </head>
> <body>
> <form runat="server" ID="Form1">
> <asp:Button id="Button1" onclick="Button1_Click" runat="server"
> Text="Button"></asp:Button>
> </form>
> </body>
> </html>
> **********************
> I'm getting this error message
> ********************************
> Configurationvalue "SendUsing" not valid.
> 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.Runtime.InteropServices.COMException:
> Configurationvalue "SendUsing" not valid.
> Source Error:
>
> Line 4:
> Line 5: Sub Button1_Click(sender As Object, e As EventArgs)
> Line 6: SmtpMail.Send( _
> Line 7: "kenneth.philp@.sverige.nu", _
> Line 8: "kenneth.philp@.sverige.nu", _
> *********************************
> I've checked that smtp services are on
> What does "Sendusing" indicate?
> Cheers.
> Kenneth

Trouble with databinding

Hi,

I'm trying to add databinding to the wizard control. Basically a user is
entering their email address and I want to validate this to a sql database
when the hit next but I cannot get this to work.

Any idea how I would go about doing this?

Thanks in advance

--

- Hayden KirkWhat you need to do is handle the NextButtonClick and
PreviousButtonClick events. In those events you can check the value
for the ActiveStepIndex which will coorespond with each of your steps.
If the right step is the current one you can run your check against the
database. If you want to cancel the step you can set the Cancel
property on the event to true.

Here is a code snippet.

protected void Wizard1_NextButtonClick(object sender,
System.Web.UI.WebControls.WizardNavigationEventArg s e)
{
bool isEmailValid = FindEmail(txtEmail.Text);
e.Cancel = ! isEmailValid();
}

You may also want to attach a custom validator to the email textbox and
then you can simply ask the validator if it is valid. It will then
automatically display the error indicator, like a red star next to the
textbox.

Brennan Stehling
http://brennan.offwhite.net/blog/
Hayden Kirk wrote:

Quote:

Originally Posted by

Hi,
>
I'm trying to add databinding to the wizard control. Basically a user is
entering their email address and I want to validate this to a sql database
when the hit next but I cannot get this to work.
>
Any idea how I would go about doing this?
>
Thanks in advance
>
--
>
- Hayden Kirk


Thanks for responding Brennan.

This is working perfectly. I was wondering though, what is the best way to
go about getting the data from the mssql database. I only need to check to
see if their email address already exists or not, possibly delete it if they
wish to unsubscribe. Can I use the sqldatasource control for this? Or is is
better to code this by hand?

I was wondering if someone could give me a quick example of doing it by
hand.

Thanks,

"Brennan Stehling" <offwhite@.gmail.comwrote in message
news:1157942127.738960.146550@.e3g2000cwe.googlegro ups.com...

Quote:

Originally Posted by

What you need to do is handle the NextButtonClick and
PreviousButtonClick events. In those events you can check the value
for the ActiveStepIndex which will coorespond with each of your steps.
If the right step is the current one you can run your check against the
database. If you want to cancel the step you can set the Cancel
property on the event to true.
>
Here is a code snippet.
>
protected void Wizard1_NextButtonClick(object sender,
System.Web.UI.WebControls.WizardNavigationEventArg s e)
{
bool isEmailValid = FindEmail(txtEmail.Text);
e.Cancel = ! isEmailValid();
}
>
You may also want to attach a custom validator to the email textbox and
then you can simply ask the validator if it is valid. It will then
automatically display the error indicator, like a red star next to the
textbox.
>
Brennan Stehling
http://brennan.offwhite.net/blog/
>
Hayden Kirk wrote:

Quote:

Originally Posted by

>Hi,
>>
>I'm trying to add databinding to the wizard control. Basically a user is
>entering their email address and I want to validate this to a sql
>database
>when the hit next but I cannot get this to work.
>>
>Any idea how I would go about doing this?
>>
>Thanks in advance
>>
>--
>>
>- Hayden Kirk


>


Here is a snippet for a basic query with ADO.NET.

using System;
using System.Data;
using System.Data.SqlClient;

class Sample
{
public static void Main()
{
SqlConnection nwindConn = new SqlConnection("Data
Source=localhost;Integrated Security=SSPI;Initial Catalog=northwind");

SqlCommand catCMD = nwindConn.CreateCommand();
catCMD.CommandText = "SELECT CategoryID, CategoryName FROM
Categories";

nwindConn.Open();

SqlDataReader myReader = catCMD.ExecuteReader();

while (myReader.Read())
{
Console.WriteLine("\t{0}\t{1}", myReader.GetInt32(0),
myReader.GetString(1));
}

myReader.Close();
nwindConn.Close();
}
}

Hayden Kirk wrote:

Quote:

Originally Posted by

Thanks for responding Brennan.
>
This is working perfectly. I was wondering though, what is the best way to
go about getting the data from the mssql database. I only need to check to
see if their email address already exists or not, possibly delete it if they
wish to unsubscribe. Can I use the sqldatasource control for this? Or is is
better to code this by hand?
>
I was wondering if someone could give me a quick example of doing it by
hand.
>
Thanks,
>
"Brennan Stehling" <offwhite@.gmail.comwrote in message
news:1157942127.738960.146550@.e3g2000cwe.googlegro ups.com...

Quote:

Originally Posted by

What you need to do is handle the NextButtonClick and
PreviousButtonClick events. In those events you can check the value
for the ActiveStepIndex which will coorespond with each of your steps.
If the right step is the current one you can run your check against the
database. If you want to cancel the step you can set the Cancel
property on the event to true.

Here is a code snippet.

protected void Wizard1_NextButtonClick(object sender,
System.Web.UI.WebControls.WizardNavigationEventArg s e)
{
bool isEmailValid = FindEmail(txtEmail.Text);
e.Cancel = ! isEmailValid();
}

You may also want to attach a custom validator to the email textbox and
then you can simply ask the validator if it is valid. It will then
automatically display the error indicator, like a red star next to the
textbox.

Brennan Stehling
http://brennan.offwhite.net/blog/
Hayden Kirk wrote:

Quote:

Originally Posted by

Hi,
>
I'm trying to add databinding to the wizard control. Basically a user is
entering their email address and I want to validate this to a sql
database
when the hit next but I cannot get this to work.
>
Any idea how I would go about doing this?
>
Thanks in advance
>
--
>
- Hayden Kirk


Thursday, March 22, 2012

Trouble with emailing

I use the following code to email from a form :

Sub sendEmail(Src As Object, E As EventArgs)
Dim msg as New MailMessage()
msg.To = "paul@dotnet.itags.org.mydomain.com"
msg.From = "fred@dotnet.itags.org.mydomain.com"
msg.Subject = "TESTING"
msg.BodyFormat = MailFormat.Html
msg.Body = "TESTING BODY"
SmtpMail.SmtpServer = "localhost"
SmtpMail.Send(msg)
msg = Nothing

end sub

But I keep getting the error message :

"The server rejected one or more recipient addresses. The server response was: 550 5.7.1 Unable to relay for paul@dotnet.itags.org.mydomain.com"

Can anyone tell me what Im doing wrong ?

P.S. I do have the appropriate Include at the top of my page:)

You are getting this error because in smtp server your relay list is empty.

Try this :

1. In IIS right-click on the Default SMTP Virtual Server and select Properties.
2. In the Properties dialog box, selec the Access tab.
3. Click on the Relay button.
4. In the Relay Restrictions dialog box, select the Allow except the list below radio button.

Tuesday, March 13, 2012

Troubles sending email with System.Net.Mail (ASP.NET 2.0)

Hi All,

I am having difficulties sending an email from a web page that I created to my own email. This particular web pages is suppose to be a feedback form where people can leave feedback about the site and it should send the message to my email. The Exception message I get is: "Failure sending mail." Here is the piece of code I use to handle the email sending. If anyone can shed some light on this issue, it would be greatly appreciated :)

protectedvoid btnSubmit_Click(object sender,EventArgs e)

{

try

{

SmtpClient emailClient =newSmtpClient();

MailMessage email =newMailMessage();

emailClient.Host ="localhost";

emailClient.Port = 25;

email.To.Add(newMailAddress("kevintrinh.n@dotnet.itags.org.gmail.com"));

email.From =newMailAddress(txtEmail.Text);

email.Subject ="Enquiry";

email.Body ="Testing";

email.IsBodyHtml =false;

emailClient.Send(email);

}

catch(Exception ex)

{

Response.Write(ex.Message);

}

}

Cheers guys

Check the SMTP logs to start troubleshooting this.

Jeff


You'll need more detailed error info to get help.

One quick thing to check, is antivirus software on your computer blocking your code from sending email?


I have a feedback page, too, and it works great. Here's my code:

The Click Event:

public void SendMail_Click(object sender, EventArgs e)

{

SendMail();

}


public void SendMail()
{
//create the mail message
MailMessage mail = new MailMessage();

//set the addresses
mail.From = new MailAddress(WebConfigurationManager.AppSettings["DefaultMailFrom"], "Internet User: " + txtName.Text);
mail.To.Add(WebConfigurationManager.AppSettings["DefaultMailTo"]);
if (txtEmail.Text.Trim() != "")
mail.ReplyTo = new MailAddress(txtEmail.Text.Trim());

//set the content
mail.Subject = txtSubject.Text;
mail.Body = txtBody.Text;
mail.Body += "\n\nReferring page: " + lnkReferrerF.NavigateUrl;

//send the message
SmtpClient smtp = new SmtpClient(WebConfigurationManager.AppSettings["DefaultMailServer"]);
smtp.Send(mail);
}

And then under <AppSettings> in the web.config file I have:

<add key="DefaultMailFrom" value="mailer@.site.com" />
<add key="DefaultMailReplyTo" value="david@.site.com" />
<add key="DefaultMailTo" value="david@.site.com" />

<add key="DefaultMailServer" value="mailserver name" />

Hope this helps.


Kevin-

If you're currently trying to run this on your local PC, make sure you have an SMTP server running on your box. Open up the IIS Configuration in your Control Panel > Administrative Tools and make sure the Default SMTP Virtual Server is started.

Thanks~


Hi everyone,

Thanks for all the insight...I really appreciate it. I will take a look at all your suggestions and follow up. Thanks again guys :)

Cheers


Dear Friend,

Also check out if you are running any anti virus scanners. Sometimes those applications blocks the port for sending out the emails. You may need to configure them to send out the emails.


tanglin05:

Kevin-

If you're currently trying to run this on your local PC, make sure you have an SMTP server running on your box. Open up the IIS Configuration in your Control Panel > Administrative Tools and make sure the Default SMTP Virtual Server is started.

Thanks~

Hi Todd,

I think this is my problem. I've taken a look on the net and all the tutorials explain the procedure to configure the virtual smtp server for all windows other than VISTA. Just wondering if you know how to configure the settings on vista or if you/anyone know of any links that may point me in the right direction?
In the mean time I will continue looking for explanations online :)

Thanks mate.


Kevin-

I'm away from my desktop right now, so I don't have Vista handy. Based on these posts I found on the Net, it appears SMTP may not be in Vista (?!):

http://tfl09.blogspot.com/2007/03/smtp-in-vista-or-not.html

http://weblogs.asp.net/steveschofield/archive/2006/12/19/iis7-post-23-vista-and-smtp-server-where-is-it.aspx

I can't verify this right now, so if anyone knows otherwise please correct me. The links I provided have references to shareware SMTP servers that you can install to solve your problem, so this may help you get on your way.

Thanks~


Todd you're a champ mate...I downloaded a free smtp server and it sends nowBig Smile');" title="Big Smile -Big Smile">

Just some tips for anyone else with a similar problem. If you are trying to send emails from you local machine, make sure the ISP you are going through does not block port 25 (else your emails cannot be sent). I found that I could send from uni but I couldn't send from home (for the above reason)

If everything seems ok with your code and server setup however you do not receive any emails.....check your SPAM folder!! (This is also what happened to me; spent 2 long hours trying to work out why I wasn't receiving any emails!)

I found the following SMTP server application to be the most useful one out there as it allows you to test whether port 25 is open. You can download the free 30day trial here1st SMTP Server

Hope this helps anyone facing the same email problems as I didSmile');" title="Smile -Smile">

Thanks again everyone for your helpYes');" title="Yes -Yes">