Wrox Programmer Forums
|
ASP.NET 1.0 and 1.1 Basics ASP.NET discussion for users new to coding in ASP.NET 1.0 or 1.1. NOT for the older "classic" ASP 3 or the newer ASP.NET 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 1.0 and 1.1 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 26th, 2005, 02:47 PM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RPG SEARCH
Default System.Web.Mail - linebreaks possible?

Hi there,

I am using the Import Namespace System.Web.Mail to send myself information from a form online. I can easily get all the information into the email and it sends nicely but my problem is it one continous string..... how do i put line breaks in there. i tried...

 & "<br />" which puts it in the text.
 & <br /> but it spits out an error...

any help would be appreciated on this one! thanks for your help!

David

David
__________________
David Jenkins
 
Old January 26th, 2005, 08:32 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

I haven't used the .NET Mail namespace yet,
But with other mail objects I have used you need to set the BodyFormat (Or similar property) to "HTML" to effect the use of "<BR/>".
Alternatively you can enter a text line break.
For c# this is "\n".
eg. messageTXT = "This is line one.\nLine two.\nLine Three";
<BR/> without the quotes will not work in any case.

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old January 26th, 2005, 08:35 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

PS. Text line break is when the BodyFormat is not "HTML",
i.e.BodyFormat is "TEXT".
Reading my message back it read as thought "\n" was an alternative to "<BR/>", which it is not.
TEXT Format is alternative to HTML, and they use \n and <BR> respectively.

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old January 27th, 2005, 10:25 AM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RPG SEARCH
Default

cheers for the response i set the newMail.BodyFormat = MailFormat.Html then used the <br /> tags. thanks for the response

David
 
Old January 27th, 2005, 12:58 PM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RPG SEARCH
Default

Ok i was testing on my localhost and it was sending me emails perfectly.... I have just deployed it to a web server and now i get an error... does anyone know what this means please.

The "SendUsing" configuration value is invalid.
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: The "SendUsing" configuration value is invalid.

Source Error:


Line 18: newMail.Body = "A user has requested information from your Kleeneze website." & "<br /><br /><br />" & txtName.Text & "<br />" & txtSurname.Text & "<br />" & txtAddress.Text & "<br />" & txtPhone.Text
Line 19:
Line 20: SmtpMail.Send(newMail) 'This sends the email.
Line 21:
Line 22:


Source File: C:\Inetpub\vhosts\1stmillion.co.uk\httpdocs\info.a spx Line: 20

Stack Trace:


[COMException (0x80040220): The "SendUsing" configuration value is invalid.
]

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters) +0
   System.RuntimeType.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParameters) +473
   System.Web.Mail.LateBoundAccessHelper.CallMethod(O bject obj, String methodName, Object[] args) +58

[HttpException (0x80004005): Could not access 'CDO.Message' object.]
   System.Web.Mail.LateBoundAccessHelper.CallMethod(O bject obj, String methodName, Object[] args) +112
   System.Web.Mail.CdoSysHelper.Send(MailMessage message) +1861
   System.Web.Mail.SmtpMail.Send(MailMessage message) +153
   ASP.info_aspx.btnSubmit_Click(Object Sender, EventArgs exc) in C:\Inetpub\vhosts\1stmillion.co.uk\httpdocs\info.a spx:20
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
   System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument) +57
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument) +18
   System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData) +33
   System.Web.UI.Page.ProcessRequestMain() +1292


Thanks for any help

David
 
Old January 27th, 2005, 01:19 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,110
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Typically this exception has to deal with the ABSENCE of the following line of code:
SmtpMail.SmtpServer = "mail.your-domain.com"
If you are using the local SMTP Service to send emails, you may try the following values:
"127.0.0.1"
"localhost"
"the_machine_name_here"
"the_real_dns_name_here"
"the_machine_IP_Address_here"

From http://www.systemwebmail.com/faq/4.2.2.aspx


 
Old January 27th, 2005, 03:50 PM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RPG SEARCH
Default

hi there,

The solution solved one problem then created another but that site managed to sort me out! Thanks to all for your help =)

David
 
Old January 27th, 2005, 05:44 PM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RPG SEARCH
Default

Ok.... sorry i wanted to ask a question this is me being a little dumb... I think i tried everything here.... how do i get the results of a checkbox into an email?

ie with textbox i do txtName.Text
with the checkbox i tried... chkBox.SelectedItem.Value .Value .Item .SelectedIndex .... none worked... ag

David
 
Old January 27th, 2005, 08:52 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 596
Thanks: 1
Thanked 3 Times in 3 Posts
Default

.Checked is the property for whether or not is has been selected.
.Text is the property for the text displayed with the checkbox.

======================================
They say, best men are molded out of faults,
And, for the most, become much more the better
For being a little bad.
======================================
 
Old January 29th, 2005, 10:54 PM
Friend of Wrox
 
Join Date: Apr 2004
Posts: 105
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to RPG SEARCH
Default

cool thanks i should have known that - lol. cheers

David





Similar Threads
Thread Thread Starter Forum Replies Last Post
System.Web.HttpException: Invalid mail attachment kapi.goel C# 4 September 6th, 2007 02:48 AM
Linebreaks GabrielMobius Pro JSP 0 March 20th, 2006 03:23 PM
Mail system vemaju Excel VBA 0 September 15th, 2004 11:53 AM
System.Web.Mail dkb General .NET 3 August 25th, 2004 07:36 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.