Welcome Guest Search | Active Topics | Members | Log In | Register

new link Options · View
Vinnie
Posted: Saturday, October 06, 2007 8:29:33 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 06/10/2007 08:29:33
Date: Sat, 06 Oct 2007 15:29:33 -0700

I have made a small form to send the mail to the websmaster, but i
don;t know how to code this action:

if the mail was sent successfully, than go to the url www.xxxyyyzzz.com

Thanks
Vinnie

Vinnie
Posted: Saturday, October 06, 2007 9:09:57 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 06/10/2007 09:09:57
Date: Sat, 06 Oct 2007 16:09:57 -0700

> Slightly modified from:http://msdn2.microsoft.com/en-us/library/swas0fwc(vs.80).aspx
>
> public static void CreateTestMessage(string server)
> {
> try
> {
> string to = "j...@contoso.com";
> string from = "b...@contoso.com";
> MailMessage message = new MailMessage(from, to);
> message.Subject = "Using the new SMTP client.";
> message.Body = "Hello";
> SmtpClient client = new SmtpClient(server);
> client.Send(message);
> Response.Redirect("www.xxxyyyzzz.com", false);
> }
> catch (Exception ex)
> {
> // do something
> }
>
> }
>
> --
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net

hi Mark, taanks a lot.

I have modified the code in this way, do you think it will work? I
have this concerns:
a) is the conversion that i placed in the TO and FROM, in the right
way?
b) in the catch function, what code should be placed?

Vinnie
Posted: Saturday, October 06, 2007 9:37:19 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 06/10/2007 09:37:19
Date: Sat, 06 Oct 2007 16:37:19 -0700

On Oct 6, 7:22 pm, "Mark Rae [MVP]" <m...@markNOSPAMrae.net> wrote:

> > a) is the conversion that i placed in the TO and FROM, in the right
> > way?
>
> Only if there is really an email address "j...@contosom.com", which seems
> unlikely...
>
> > b) in the catch function, what code should be placed?
>
> Depends how you're doing your exception handling... If you don't need to
> handle the expection in this code, it will bubble up to the calling
> method...
>
> --
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net

I got this error msg, what's about?

CS0246: The type or namespace name 'MailMessage' could not be found
(are you missing a using directive or an assembly reference?)

Mark Rae [MVP]
Posted: Sunday, October 07, 2007 12:42:34 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 07/10/2007 00:42:34
Date: Sat, 6 Oct 2007 23:42:34 +0100

"Vinnie" <centro.gamma@gmail.com> wrote in message
news:1191709773.968795.296000@y42g2000hsy.googlegroups.com...

>I have made a small form to send the mail to the websmaster, but i
> don;t know how to code this action:
>
> if the mail was sent successfully, than go to the url www.xxxyyyzzz.com

Slightly modified from:
http://msdn2.microsoft.com/en-us/library/swas0fwc(vs.80).aspx

public static void CreateTestMessage(string server)
{
try
{
string to = "jane@contoso.com";
string from = "ben@contoso.com";
MailMessage message = new MailMessage(from, to);
message.Subject = "Using the new SMTP client.";
message.Body = "Hello";
SmtpClient client = new SmtpClient(server);
client.Send(message);
Response.Redirect("www.xxxyyyzzz.com", false);
}
catch (Exception ex)
{
// do something
}
}


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Mark Rae [MVP]
Posted: Sunday, October 07, 2007 1:22:08 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 07/10/2007 01:22:08
Date: Sun, 7 Oct 2007 00:22:08 +0100

"Vinnie" <centro.gamma@gmail.com> wrote in message
news:1191712197.555753.102300@y42g2000hsy.googlegroups.com...

>> public static void CreateTestMessage(string server)
>> {
>> try
>> {
>> string to = "j...@contoso.com";
>> string from = "b...@contoso.com";
>> MailMessage message = new MailMessage(from, to);
>> message.Subject = "Using the new SMTP client.";
>> message.Body = "Hello";
>> SmtpClient client = new SmtpClient(server);
>> client.Send(message);
>> Response.Redirect("www.xxxyyyzzz.com", false);
>> }
>> catch (Exception ex)
>> {
>> // do something
>> }
>>
>> }

> I have modified the code in this way, do you think it will work? I
> have this concerns:
> a) is the conversion that i placed in the TO and FROM, in the right
> way?

Only if there is really an email address "j...@contosom.com", which seems
unlikely...

> b) in the catch function, what code should be placed?

Depends how you're doing your exception handling... If you don't need to
handle the expection in this code, it will bubble up to the calling
method...


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Mark Rae [MVP]
Posted: Sunday, October 07, 2007 1:55:11 AM


Rank: Guest
Groups: Guest

Joined: 9/17/2007
Posts: 11,670
Points: -1,200
Date parsed: 07/10/2007 01:55:11
Date: Sun, 7 Oct 2007 00:55:11 +0100

"Vinnie" <centro.gamma@gmail.com> wrote in message
news:1191713839.620573.140770@k79g2000hse.googlegroups.com...

> I got this error msg, what's about?
>
> CS0246: The type or namespace name 'MailMessage' could not be found
> (are you missing a using directive or an assembly reference?)

It means you haven't included System.Net at the top of your class:
http://www.systemnetmail.com/


--
Mark Rae
ASP.NET MVP
http://www.markrae.net

Users browsing this topic
Guest


Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Main Forum RSS : RSS

YAFPro Theme Created by Jaben Cargman (Tiny Gecko)
Powered by Yet Another Forum.net version 1.9.1.1 (NET v2.0) - 9/10/2007
Copyright © 2003-2006 Yet Another Forum.net. All rights reserved.
This page was generated in 0.071 seconds.