Showing posts with label wizard. Show all posts
Showing posts with label wizard. Show all posts

Saturday, March 24, 2012

System.Net.Mail.SmtpClient.Send() Error: An invalid character was found in the mail header

hi all!

please help!

I wanted to make an automatic email when I create user by CreateUserWizard. So I configured SMTP, then in properties of the wizard indicated textfile for message and wrote simple subject "registration"

but I have an exception (like in subj).

I even tried to set the subject in event handler for "emailsending" event. Same exception.

What is wrong? How could I fix it?

Here us some info from stack:

[FormatException:An invalid character was found in the mail header.] System.Net.BufferBuilder.Append(String value, Int32 offset, Int32 count) +915954 System.Net.Mail.EHelloCommand.PrepareCommand(SmtpConnection conn, String domain) +106 System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port) +835 System.Net.Mail.SmtpTransport.GetConnection(String host, Int32 port) +316 System.Net.Mail.SmtpClient.GetConnection() +42 System.Net.Mail.SmtpClient.Send(MailMessage message) +1485

[SmtpException: Email send failure.] System.Net.Mail.SmtpClient.Send(MailMessage message) +2074 System.Web.UI.WebControls.LoginUtil.SendPasswordMail(String email, String userName, String password, MailDefinition mailDefinition, String defaultSubject, String defaultBody, OnSendingMailDelegate onSendingMailDelegate, OnSendMailErrorDelegate onSendMailErrorDelegate, Control owner) +341 System.Web.UI.WebControls.CreateUserWizard.AttemptCreateUser() +571 System.Web.UI.WebControls.CreateUserWizard.OnNextButtonClick(WizardNavigationEventArgs e) +105 System.Web.UI.WebControls.Wizard.OnBubbleEvent(Object source, EventArgs e) +453 System.Web.UI.WebControls.CreateUserWizard.OnBubbleEvent(Object source, EventArgs e) +149 System.Web.UI.WebControls.WizardChildTable.OnBubbleEvent(Object source, EventArgs args) +17 System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35 System.Web.UI.WebControls.ImageButton.OnCommand(CommandEventArgs e) +115 System.Web.UI.WebControls.ImageButton.RaisePostBackEvent(String eventArgument) +171 System.Web.UI.WebControls.ImageButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +33 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

Hi there, can i just ask why you choose me? as for your problem, it looks like there is an invalid character in the mail header, so either there is nothing in it or something there shouldnt be, try taking a few steps back, if your attaching a text file just simply put a few words coded in, and if your header is dynamic try making it hard coded


You were online. Sorry.

It is more simple. There is simpliest string, like "123". Same error


hey no worries, well try a string like abc, also make sure no fields are not left blank. What usually helps me is take a 10 min break, clear you head have a coffee and come back look through your code as if you have never seen it before. something may catch. Im not the worlds best .neter but i usually find if there is a problem its often by taking things back to basic it helps


If your still not having any success you could try the code below and see if it makes any difference.

Regards

Martijn

Sub mailout()Dim mailAsNew Net.Mail.MailMessage()

'set the addresses

mail.To.Add("recipient@.whereever.com")

mail.From =New Net.Mail.MailAddress("sender@.wherever.com"))

'set the content

mail.Subject ="Email Subject line"

mail.Body ="The main body of the email message"

'send the message

Dim smtpAsNew Net.Mail.SmtpClient("smtp.whereever.com")

'to authenticate we set the username and password properites on the SmtpClient

smtp.Credentials =New Net.NetworkCredential("smtp-accountname e.g. sender@.wherever.com","smtp-account-password")

Try

smtp.Send(mail)

response.write("Email sent successfully")

Catch ExAs Exception

response.write("Email send failed error code is... " & Ex.Message)

EndTry

EndSub


no success, same error


I cant come up with any conclusions from your stack trace.

The code I gave you I copied out of an application I wrote there was something I had missed and should have cleaned up in the following line

mail.From =New Net.Mail.MailAddress(Session(sender@.wherever.com))

It should be this (no reference to any session variable)

mail.From =New Net.Mail.MailAddress(sender@.wherever.com)

The only other question is does your recipient or sender email address have any unusual charactors or attempt to have a space in it? Any thing like that could cause a problem. Try the same code with different email addresses and different content.

Sorry no other suggestions

Martijn


May be this piece of code will help:

<system.net>
<mailSettings>
<smtp from="evdokp@.pochta.ru">
<network host="mail.pochta.ru" password="[мой пароль]" userName="evdokp@.pochta.ru" />
</smtp>
</mailSettings>
</system.net>

this is how ASP.NET build-it configuration tool edits web.config

Well, my additional question is: where does the tool sets port value?


ok, my sugesstion is to take remove the brackets from the password and to use a password with standard English character set without and spaces.

Be sure to update the password on the mail server too.

Good luck

<system.net>
<mailSettings>
<smtp from="evdokp@.pochta.ru">
<network host="mail.pochta.ru" password="myPassword" userName="evdokp@.pochta.ru" />
</smtp>
</mailSettings>
</system.net>


it is not that easy.

these brackets are there just because I hide my password. It was like you say "myPassword"

Do you know where port is defined in web.config?

Thursday, March 22, 2012

System.OutOfMemory Exception urgent Help pls

Hi Guys,

I have a real serious problem that stoped me doing any progress in my project.

in one of my webpages I have a wizard of more then 13 pages and in every page some Ajax controls, textboxes, dropdownlists, about 4 panels, where every page in my wizard have almost the same controls;

so all what I had to do is copy the controls from a wizard page then paste it to next one and just change the controls names and it was going all fine till the page 8 in my wizard where pasting this set of controls is now giving me this error "System.OutOfMemory Exception" and this is happening at design time, and even just browsing between the wizard pages at design time is giving me the same error.

I thought that the wizard plus these controls are consuming too much memory so I changed my design and deleted the wizard and used MultiView instead but still the same problem.

So help me pls, or how can I increase the memory space used by Visual Studio knowing that my pc's RAM is 2G and still have 30G free disk space!!!!?

Thanks
Regards,
M.RochdiYou say that the code is almost the same in all pages, lets see the code and
what the differences are.
When you used the MultiView what page did you get the error on?
You may need to add code bit by bit find the problem.
What do the pages do, is it possible that your machine is running out of
memory without an error?
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:EBE6EFED-83EB-4648-930E-A33A66C3F9CC@.microsoft.com...
> Hi Guys,
> I have a real serious problem that stoped me doing any progress in my
> project.
> in one of my webpages I have a wizard of more then 13 pages and in every
> page some Ajax controls, textboxes, dropdownlists, about 4 panels, where
> every page in my wizard have almost the same controls; so all what I had
> to
> do is copy the controls from a wizard page then paste it to next one and
> just
> change the controls names and it was going all fine till the page 8 in my
> wizard where pasting this set of controls is now giving me this error
> "System.OutOfMemory Exception" and this is happening at design time, and
> even
> just browsing between the wizard pages at design time is giving me the
> same
> error. I thought that the wizard plus these controls are consuming too
> much
> memory so I changed my design and deleted the wizard and used MultiView
> instead but still the same problem. So help me pls, or how can I increase
> the
> memory space used by Visual Studio knowing that my pc's RAM is 2G and
> still
> have 30G free disk space!!!!?
>
> Thanks
>
> --
> Regards,
> M.Rochdi
You say that the code is almost the same in all pages, lets see the code and
what the differences are.
I said that the controls are almost the same in every wizard page witch
means the Design code would be almost the same, but its really too long to
cut and past it in my post.
When you used the MultiView what page did you get the error on?
with MultiView there was only one page. I deleted the wizard witch means all
its pages and I used a MultiView instead with 13 Views in my webpage and whe
n
trying to add more controls to View 8 or 9 that error will start to come up
in the add control it self. but anyway, when having the wizard just browsing
backward and forward between the wizard pages at design time will give the
same error.
What do the pages do?
the controls in the page will change to a Gray box will the above error.
is it possible that your machine is running out of
memory without an error?
Well I do have 2G RAM and when I checked the Performance of my CPU it was
only from 1% to 40% but I don't know how much memory is conserved to Visual
Studio to work and I've heard that you can increase the memory that VS can
work on but I don't know How?
Regards,
M.Rochdi
"ThatsIT.net.au" wrote:

> You say that the code is almost the same in all pages, lets see the code a
nd
> what the differences are.
> When you used the MultiView what page did you get the error on?
> You may need to add code bit by bit find the problem.
> What do the pages do, is it possible that your machine is running out of
> memory without an error?
>
> "Mike" <Mike@.discussions.microsoft.com> wrote in message
> news:EBE6EFED-83EB-4648-930E-A33A66C3F9CC@.microsoft.com...
>

System.OutOfMemoryException problem

Hi Guys,
I have an aspx page that include some Ajax components (UpdatePanel,
ProgressBar, Extenders) and a wizard for about 15 pages and in every page I
am adding some labels, textboxes, dropdownlists, checkboxes.
and now I'm up to page 8 in my wizard and if I add some more controls in my
wizard page or even moving backward or forward to another wizard page some o
f
the controls will change to gray box with an error like this eg. -(Error
Creating Control -Label65 Exception of type 'System.OutOfMemoryException'
Was Thrown).
I tried close and reopen the application or to restart the computer but
still getting the same error!!!?
Thanks
Regards,
M.RochdiWhat is the system usage of memory like when you start to walk through the
different pages of the wizard? Does it continue to grow?
--
Regards,
Alvin Bruney [MVP ASP.NET]
[Shameless Author plug]
The O.W.C. Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $19.99
"Mike" <Mike@.discussions.microsoft.com> wrote in message
news:2846DA5C-FE2C-47D0-8828-AB82CF8DBCFE@.microsoft.com...
> Hi Guys,
> I have an aspx page that include some Ajax components (UpdatePanel,
> ProgressBar, Extenders) and a wizard for about 15 pages and in every page
> I
> am adding some labels, textboxes, dropdownlists, checkboxes.
> and now I'm up to page 8 in my wizard and if I add some more controls in
> my
> wizard page or even moving backward or forward to another wizard page some
> of
> the controls will change to gray box with an error like this eg. -(Error
> Creating Control -Label65 Exception of type 'System.OutOfMemoryException'
> Was Thrown).
> I tried close and reopen the application or to restart the computer but
> still getting the same error!!!?
>
> Thanks
> --
> Regards,
> M.Rochdi