473,409 Members | 1,942 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,409 software developers and data experts.

MailMessage Problem

Using the code below, I am trying to send an email from an ASP.NET 2.0 page
but I get the error " The specified string is not in the form required for
an e-mail address." when the "Dim Mailmsg..." line is executed. Since I
haven't defined the from/to yet, I don't understand what it wants? Any
insight on what causes this?
=========================================
Dim obj As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient
Dim Mailmsg As New System.Net.Mail.MailMessage
Mailmsg.To.Clear()
Mailmsg.To.Add(New System.Net.Mail.MailAddress("To Name
<to****@todomain.com>")
Mailmsg.From = New System.Net.Mail.MailAddress("From Name
<fr******@yourfromdomain.com>")
Mailmsg.Subject = "(subject text)"
Try
Mailmsg.Body = "(message text here)"
obj.Send(Mailmsg)
Catch ex As Exception
Response.Write("Error: " & ex.ToString())
End Try
=========================================
Mar 12 '06 #1
7 1201
re:
Since I haven't defined the from/to yet
Actually, you *have* defined it, as :

Mailmsg.To.Add(New System.Net.Mail.MailAddress("To Name <to****@todomain.com>")
Mailmsg.From = New System.Net.Mail.MailAddress("From Name <fr******@yourfromdomain.com>")

It's expecting a mail address in the form :

new MailAddress("so******@somewhere.com", "Some Name");

Try :

Mailmsg.To.Add(New System.Net.Mail.MailAddress("to****@todomain.com", "To Name")
Mailmsg.From = New System.Net.Mail.MailAddress("fr******@yourfromdoma in.com", "From Name")


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Wayne Wengert" <wa***********@wengert.org> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl... Using the code below, I am trying to send an email from an ASP.NET 2.0 page but I get the error "
The specified string is not in the form required for an e-mail address." when the "Dim Mailmsg..."
line is executed. Since I haven't defined the from/to yet, I don't understand what it wants? Any
insight on what causes this?
=========================================
Dim obj As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient
Dim Mailmsg As New System.Net.Mail.MailMessage
Mailmsg.To.Clear()
Mailmsg.To.Add(New System.Net.Mail.MailAddress("To Name <to****@todomain.com>")
Mailmsg.From = New System.Net.Mail.MailAddress("From Name <fr******@yourfromdomain.com>")
Mailmsg.Subject = "(subject text)"
Try
Mailmsg.Body = "(message text here)"
obj.Send(Mailmsg)
Catch ex As Exception
Response.Write("Error: " & ex.ToString())
End Try
=========================================

Mar 12 '06 #2
I hsould have added...

See http://msdn2.microsoft.com/en-us/lib...iladdress.aspx
and http://msdn2.microsoft.com/en-us/lib...kf(VS.80).aspx

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:uz**************@TK2MSFTNGP12.phx.gbl...
re:
Since I haven't defined the from/to yet


Actually, you *have* defined it, as :

Mailmsg.To.Add(New System.Net.Mail.MailAddress("To Name <to****@todomain.com>")
Mailmsg.From = New System.Net.Mail.MailAddress("From Name <fr******@yourfromdomain.com>")

It's expecting a mail address in the form :

new MailAddress("so******@somewhere.com", "Some Name");

Try :

Mailmsg.To.Add(New System.Net.Mail.MailAddress("to****@todomain.com", "To Name")
Mailmsg.From = New System.Net.Mail.MailAddress("fr******@yourfromdoma in.com", "From Name")


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Wayne Wengert" <wa***********@wengert.org> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Using the code below, I am trying to send an email from an ASP.NET 2.0 page but I get the error "
The specified string is not in the form required for an e-mail address." when the "Dim
Mailmsg..." line is executed. Since I haven't defined the from/to yet, I don't understand what it
wants? Any insight on what causes this?
=========================================
Dim obj As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient
Dim Mailmsg As New System.Net.Mail.MailMessage
Mailmsg.To.Clear()
Mailmsg.To.Add(New System.Net.Mail.MailAddress("To Name <to****@todomain.com>")
Mailmsg.From = New System.Net.Mail.MailAddress("From Name <fr******@yourfromdomain.com>")
Mailmsg.Subject = "(subject text)"
Try
Mailmsg.Body = "(message text here)"
obj.Send(Mailmsg)
Catch ex As Exception
Response.Write("Error: " & ex.ToString())
End Try
=========================================


Mar 12 '06 #3
I'm confused. The error occurs on the "Dim Mailmsg..." before the To and
From addresses are set?

Wayne

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:uz**************@TK2MSFTNGP12.phx.gbl...
re:
Since I haven't defined the from/to yet


Actually, you *have* defined it, as :

Mailmsg.To.Add(New System.Net.Mail.MailAddress("To Name
<to****@todomain.com>")
Mailmsg.From = New System.Net.Mail.MailAddress("From Name
<fr******@yourfromdomain.com>")

It's expecting a mail address in the form :

new MailAddress("so******@somewhere.com", "Some Name");

Try :

Mailmsg.To.Add(New System.Net.Mail.MailAddress("to****@todomain.com", "To
Name")
Mailmsg.From = New
System.Net.Mail.MailAddress("fr******@yourfromdoma in.com", "From Name")


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Wayne Wengert" <wa***********@wengert.org> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Using the code below, I am trying to send an email from an ASP.NET 2.0
page but I get the error " The specified string is not in the form
required for an e-mail address." when the "Dim Mailmsg..." line is
executed. Since I haven't defined the from/to yet, I don't understand
what it wants? Any insight on what causes this?
=========================================
Dim obj As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient
Dim Mailmsg As New System.Net.Mail.MailMessage
Mailmsg.To.Clear()
Mailmsg.To.Add(New System.Net.Mail.MailAddress("To Name
<to****@todomain.com>")
Mailmsg.From = New System.Net.Mail.MailAddress("From Name
<fr******@yourfromdomain.com>")
Mailmsg.Subject = "(subject text)"
Try
Mailmsg.Body = "(message text here)"
obj.Send(Mailmsg)
Catch ex As Exception
Response.Write("Error: " & ex.ToString())
End Try
=========================================


Mar 12 '06 #4
Sure, that's standard OOP procedure.

When you call an object, all of its components are called, too.

Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Wayne Wengert" <wa***********@wengert.org> wrote in message
news:ua**************@TK2MSFTNGP09.phx.gbl...
I'm confused. The error occurs on the "Dim Mailmsg..." before the To and From addresses are set?

Wayne

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:uz**************@TK2MSFTNGP12.phx.gbl...
re:
Since I haven't defined the from/to yet


Actually, you *have* defined it, as :

Mailmsg.To.Add(New System.Net.Mail.MailAddress("To Name <to****@todomain.com>")
Mailmsg.From = New System.Net.Mail.MailAddress("From Name <fr******@yourfromdomain.com>")

It's expecting a mail address in the form :

new MailAddress("so******@somewhere.com", "Some Name");

Try :

Mailmsg.To.Add(New System.Net.Mail.MailAddress("to****@todomain.com", "To Name")
Mailmsg.From = New System.Net.Mail.MailAddress("fr******@yourfromdoma in.com", "From Name")


Juan T. Llibre, asp.net MVP
aspnetfaq.com : http://www.aspnetfaq.com/
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"Wayne Wengert" <wa***********@wengert.org> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Using the code below, I am trying to send an email from an ASP.NET 2.0 page but I get the error
" The specified string is not in the form required for an e-mail address." when the "Dim
Mailmsg..." line is executed. Since I haven't defined the from/to yet, I don't understand what
it wants? Any insight on what causes this?
=========================================
Dim obj As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient
Dim Mailmsg As New System.Net.Mail.MailMessage
Mailmsg.To.Clear()
Mailmsg.To.Add(New System.Net.Mail.MailAddress("To Name <to****@todomain.com>")
Mailmsg.From = New System.Net.Mail.MailAddress("From Name <fr******@yourfromdomain.com>")
Mailmsg.Subject = "(subject text)"
Try
Mailmsg.Body = "(message text here)"
obj.Send(Mailmsg)
Catch ex As Exception
Response.Write("Error: " & ex.ToString())
End Try
=========================================



Mar 12 '06 #5
I have 2.0 example mail code at my blog.

with several different authentication options.

http://spaces.msn.com/sholliday

2/8/2006 entry
"Wayne Wengert" <wa***********@wengert.org> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Using the code below, I am trying to send an email from an ASP.NET 2.0 page but I get the error " The specified string is not in the form required for
an e-mail address." when the "Dim Mailmsg..." line is executed. Since I
haven't defined the from/to yet, I don't understand what it wants? Any
insight on what causes this?
=========================================
Dim obj As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient
Dim Mailmsg As New System.Net.Mail.MailMessage
Mailmsg.To.Clear()
Mailmsg.To.Add(New System.Net.Mail.MailAddress("To Name
<to****@todomain.com>")
Mailmsg.From = New System.Net.Mail.MailAddress("From Name
<fr******@yourfromdomain.com>")
Mailmsg.Subject = "(subject text)"
Try
Mailmsg.Body = "(message text here)"
obj.Send(Mailmsg)
Catch ex As Exception
Response.Write("Error: " & ex.ToString())
End Try
=========================================

Mar 12 '06 #6
Sloan;

Thanks for that response - You pointed me in what I am sure is the right
direction. I am trying to get the web.config settings right for my
environment (Comcast). It seems that comcast does not require authorization
but there must be something else I overlooked as I am getting the following
error;

Mailbox unavailable. The server response was: [PERMFAIL] comcast.net
requires valid sender domain

I am not sure exactly what it wants - I did try my comcast login and PW but
that had no effect?

Wayne
"sloan" <sl***@ipass.net> wrote in message
news:ON*************@TK2MSFTNGP10.phx.gbl...
I have 2.0 example mail code at my blog.

with several different authentication options.

http://spaces.msn.com/sholliday

2/8/2006 entry
"Wayne Wengert" <wa***********@wengert.org> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Using the code below, I am trying to send an email from an ASP.NET 2.0

page
but I get the error " The specified string is not in the form required
for
an e-mail address." when the "Dim Mailmsg..." line is executed. Since I
haven't defined the from/to yet, I don't understand what it wants? Any
insight on what causes this?
=========================================
Dim obj As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient
Dim Mailmsg As New System.Net.Mail.MailMessage
Mailmsg.To.Clear()
Mailmsg.To.Add(New System.Net.Mail.MailAddress("To Name
<to****@todomain.com>")
Mailmsg.From = New System.Net.Mail.MailAddress("From Name
<fr******@yourfromdomain.com>")
Mailmsg.Subject = "(subject text)"
Try
Mailmsg.Body = "(message text here)"
obj.Send(Mailmsg)
Catch ex As Exception
Response.Write("Error: " & ex.ToString())
End Try
=========================================


Mar 12 '06 #7
I got it working. That last problem was caused by my use of a domain that
had not been activated yet in the From address.

Wayne

"Wayne Wengert" <wa***********@wengert.org> wrote in message
news:em**************@tk2msftngp13.phx.gbl...
Sloan;

Thanks for that response - You pointed me in what I am sure is the right
direction. I am trying to get the web.config settings right for my
environment (Comcast). It seems that comcast does not require
authorization but there must be something else I overlooked as I am
getting the following error;

Mailbox unavailable. The server response was: [PERMFAIL] comcast.net
requires valid sender domain

I am not sure exactly what it wants - I did try my comcast login and PW
but that had no effect?

Wayne
"sloan" <sl***@ipass.net> wrote in message
news:ON*************@TK2MSFTNGP10.phx.gbl...
I have 2.0 example mail code at my blog.

with several different authentication options.

http://spaces.msn.com/sholliday

2/8/2006 entry
"Wayne Wengert" <wa***********@wengert.org> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
Using the code below, I am trying to send an email from an ASP.NET 2.0

page
but I get the error " The specified string is not in the form required
for
an e-mail address." when the "Dim Mailmsg..." line is executed. Since I
haven't defined the from/to yet, I don't understand what it wants? Any
insight on what causes this?
=========================================
Dim obj As System.Net.Mail.SmtpClient = New System.Net.Mail.SmtpClient
Dim Mailmsg As New System.Net.Mail.MailMessage
Mailmsg.To.Clear()
Mailmsg.To.Add(New System.Net.Mail.MailAddress("To Name
<to****@todomain.com>")
Mailmsg.From = New System.Net.Mail.MailAddress("From Name
<fr******@yourfromdomain.com>")
Mailmsg.Subject = "(subject text)"
Try
Mailmsg.Body = "(message text here)"
obj.Send(Mailmsg)
Catch ex As Exception
Response.Write("Error: " & ex.ToString())
End Try
=========================================



Mar 13 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Simran | last post by:
I need to set up an automated email system , which means users should not be able to respond back to the emails but at the same time, we need to track bounced emails. This is important as our...
1
by: Trond A. S. Andersen | last post by:
Hi all, I'm working on a project in which i need to send mail attachments in the form of Excel documents from a .NET C# application. I've written a class which creates the Excel document using...
2
by: Richard Bogle | last post by:
Hi, MailMessage.From allows me to set the email address that the message comes from but not the "covering address" (sorry, no idea what the correct terminology might be). The email message...
4
by: Trond A. S. Andersen | last post by:
Hi, all! I'm trying to use the System.Web.Mail. "package" combinded with System.Web.Mail.SmtpMail in order to send MS Excel spreadsheets attached to mail messages. However, sending one single...
3
by: Simon Knox | last post by:
Hi I have come across an apparant bug while using SmtpMail. The problem I have is that if a MailAttachment has a line in it that starts with a fullstop ( or period for those of you that speak...
3
by: Phil Mc | last post by:
Hi has anyone come accross the problem.... with referance to System.Web.Mail.MailMessage and System.Web.Mail.SmtpMail THIS WORKS FINE mail=new MailMessage(); mail.From =...
5
by: martin | last post by:
Hi, I have created a class that is totally seperate from my web application. However this class is used extensivly by the web application for stuff like data access. I wish to add a function to...
4
by: Aren Cambre | last post by:
Why does SmtpMail.Send throw an exception if the MailMessage's BodyFormat = MailFormat.Html? I've searched all over the place and cannot find a solution anywhere. I am running this on Windows XP...
0
by: Kevin Hodgson | last post by:
I'm having a problem with System.Web.Mail.MailMessage losing linefeeds when creating an email. This is a VB.NET project. I use a stringbuilder to construct the MailMessage.Body and use vbCrLf...
2
by: =?Utf-8?B?Q2FwdGFpbiBEYXZlIQ==?= | last post by:
I wrote some code to send an email with two alternate views: 1) html 2) plain text All the html enabled email clients accept the html just fine and disregard the plain text version. However,...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.