Showing posts with label sends. Show all posts
Showing posts with label sends. Show all posts

Thursday, March 22, 2012

Newbie:sending German characters on TCP link

Hi,

I've a .NET application that sends XML string as bytes on a TCP
connection. It had used ASCII encoding so far and everything was fine. Now
on a German OS, German characters were sent as question mark in the received
string. I guess that's because ASCII encoding was used and unicode encoding
should be used instead. But then would byte ordering(little endian ir big
endian) be a problem because the received TCP stream could be consumed by
both a Java and .NET clients ? What could be done to ensure that the
received unicode encoded XML stream be decoded by both .NET and Java clients
? And, which encoding .NET class be used utf8, utf32,.. ? Is there a sample
anywhere ?

Thanks in advance and regards

NavinOn Feb 27, 7:44 pm, "Navin Mishra" <navin.mis...@.siemens.comwrote:

Quote:

Originally Posted by

Hi,
>
I've a .NET application that sends XML string as bytes on a TCP
connection. It had used ASCII encoding so far and everything was fine. Now
on a German OS, German characters were sent as question mark in the received
string. I guess that's because ASCII encoding was used and unicode encoding
should be used instead. But then would byte ordering(little endian ir big
endian) be a problem because the received TCP stream could be consumed by
both a Java and .NET clients ? What could be done to ensure that the
received unicode encoded XML stream be decoded by both .NET and Java clients
? And, which encoding .NET class be used utf8, utf32,.. ? Is there a sample
anywhere ?
>


This group is for ASP.NET

Regarding your problem

First of all, ensure that the xml is encoded

sXML = "<?xml version=""1.0"" encoding=""windows-1252""?

Quote:

Originally Posted by

>.........."


then set this encoding to the method which send the data.

For example

myWriter = New System.IO.StreamWriter(xmlRequest.GetRequestStream (),
Encoding.GetEncoding(1252))
myWriter.Write(sXML)

I used German code page 1252 here, but you can consider to use utf-8...
Thus wrote Navin,

Quote:

Originally Posted by

Hi,
>
I've a .NET application that sends XML string as bytes on a TCP
connection. It had used ASCII encoding so far and everything was fine.
Now on a German OS, German characters were sent as question mark in
the received string. I guess that's because ASCII encoding was used
and unicode encoding should be used instead.


Absolutely. If not Unicode, then at least some 8 bit encoding like ISO Latin
1.

Quote:

Originally Posted by

But then would byte
ordering(little endian ir big endian) be a problem because the
received TCP stream could be consumed by both a Java and .NET clients
?


No. All UTF-16/32 variants include byte order marks that allow the receiver
to pick up the appropriate byte order, and UTF-8 is the same for both Big
Endian and Little Endian systems.

Quote:

Originally Posted by

What could be done to ensure that the received unicode encoded XML
stream be decoded by both .NET and Java clients ? And, which encoding
.NET class be used utf8, utf32,.. ? Is there a sample anywhere ?


If your XML contains mostly Latin characters, use UTF-8. That'll require
the least bandwidth. You can write an XML document to any stream using either
an XmlWriter or XmlDocument.Save().

Cheers,
--
Joerg Jooss
news-reply@.joergjooss.de

Newbie:sending German characters on TCP link

Hi,
I've a .NET application that sends XML string as bytes on a TCP
connection. It had used ASCII encoding so far and everything was fine. Now
on a German OS, German characters were sent as question mark in the received
string. I guess that's because ASCII encoding was used and unicode encoding
should be used instead. But then would byte ordering(little endian ir big
endian) be a problem because the received TCP stream could be consumed by
both a Java and .NET clients ? What could be done to ensure that the
received unicode encoded XML stream be decoded by both .NET and Java clients
? And, which encoding .NET class be used utf8, utf32,.. ? Is there a sample
anywhere ?
Thanks in advance and regards
NavinOn Feb 27, 7:44 pm, "Navin Mishra" <navin.mis...@.siemens.com> wrote:
> Hi,
> I've a .NET application that sends XML string as bytes on a TCP
> connection. It had used ASCII encoding so far and everything was fine. Now
> on a German OS, German characters were sent as question mark in the receiv
ed
> string. I guess that's because ASCII encoding was used and unicode encodin
g
> should be used instead. But then would byte ordering(little endian ir big
> endian) be a problem because the received TCP stream could be consumed by
> both a Java and .NET clients ? What could be done to ensure that the
> received unicode encoded XML stream be decoded by both .NET and Java clien
ts
> ? And, which encoding .NET class be used utf8, utf32,.. ? Is there a sampl
e
> anywhere ?
>
This group is for ASP.NET
Regarding your problem
First of all, ensure that the xml is encoded
sXML = "<?xml version=""1.0"" encoding=""windows-1252""?
>.........."
then set this encoding to the method which send the data.
For example
myWriter = New System.IO.StreamWriter(xmlRequest.GetRequestStream(),
Encoding.GetEncoding(1252))
myWriter.Write(sXML)
I used German code page 1252 here, but you can consider to use utf-8...
Thus wrote Navin,

> Hi,
> I've a .NET application that sends XML string as bytes on a TCP
> connection. It had used ASCII encoding so far and everything was fine.
> Now on a German OS, German characters were sent as question mark in
> the received string. I guess that's because ASCII encoding was used
> and unicode encoding should be used instead.
Absolutely. If not Unicode, then at least some 8 bit encoding like ISO Latin
1.

> But then would byte
> ordering(little endian ir big endian) be a problem because the
> received TCP stream could be consumed by both a Java and .NET clients
> ?
No. All UTF-16/32 variants include byte order marks that allow the receiver
to pick up the appropriate byte order, and UTF-8 is the same for both Big
Endian and Little Endian systems.

> What could be done to ensure that the received unicode encoded XML
> stream be decoded by both .NET and Java clients ? And, which encoding
> .NET class be used utf8, utf32,.. ? Is there a sample anywhere ?
If your XML contains mostly Latin characters, use UTF-8. That'll require
the least bandwidth. You can write an XML document to any stream using eithe
r
an XmlWriter or XmlDocument.Save().
Cheers,
--
Joerg Jooss
news-reply@.joergjooss.de

Friday, March 16, 2012

Newsletter application

I need help on creating newsletter application which creates database with name and emailaddress and sends out newsletter every month using asp.net 2.0. I need to know how to create and send news letter?

What part are you stuck on? To tell you how to program a newsletter application would take a small book. Have you looked at existing products?

Jeff


So far I only know to create front end so that user can enter their email address and subscribe or unsubscribe.

I want to know how to create Newsletter (with html, dhtml, javascript...etc very dynamic newsletter) and email every month. (this part I dont understand). There are third party products available but them might be using asp.net or some other program, I want to try myself.

can you please guide me from here?


I would suggest using the FreeTextBox control (rich, HTML type textbox), for entering your newsletter information, which is available here:
http://freetextbox.com

Then, checkout this tutorial atASPNet101.com:
http://aspnet101.com/aspnet101/tutorials.aspx?id=41


I am able to send multiple email with plain text but when I try to attach colors, pictures, formatting etc it's not working form me.

is it possible to create newsletter in Frontpage or Flash etc and attach as part of email (not as attachment). or some other better way.

I looked into free text control but I still need to figure out how to make that work.


What part isnt working, and have you made sure and used the isbodyhtml = true in your code creating the message, that is an important step.

Colors, fonts, solid tables ect are easy if you can get your email to send in html. Images are a bit different, you can either hard link them to an external server, like <img src=http://myserver.com/image.jpg /> or you need to embed the image into the email itself, much like outlook or outlook express does it Fire up OE and look at the source to a message that has an embeded picture (not an attached one).


how can I embed a HTML page created in Frontpage , flash etc as newsletter to multiple addresses?


Save to a file and attach it or copy the rendered HTML and paste it into the message. Neither are a good way to send HTML email though.

Jeff


what other options I have to make it work better? I dont want to buy any third party product. An good example will help me understand better.

Define better...your asking very general questions. Do you need help creating an html email through code? Do you have an error your getting when you try to send an email through your server using asp.net?

Do you not know how to write HTML, so that you can paste it into a mail message?

Try this...This just gets the body of the message from a text / html file. I copied an IBM newsletter that I had gotten in an email, to a textfile in my solution called...textfile.txt...original huh.

Imports

System.Net.Mail

Imports

System.IOProtectedSub DoEmail()Dim msgAsString = ReadTextFile()Dim myClientAsNew SmtpClientDim myMessageAsNew MailMessageTry

myMessage.From =

New MailAddress("email@.email.com")

myMessage.To.Add(

"to@.email.com")

myMessage.Subject =

"My Subject"

myMessage.IsBodyHtml =

True

myMessage.Body = msg

myClient.Host =

"mailserver"

myClient.Port = 25

myClient.Send(myMessage)

Catch exAs Exception

Response.Write(ex.ToString)

EndTry

EndSubProtectedFunction ReadTextFile()AsStringDim myFileAsString = Server.MapPath("textfile.txt")Dim SRAs StreamReaderTry

SR = File.OpenText(myFile)

ReadTextFile = SR.ReadToEnd()

Catch exAs Exception

ReadTextFile = ex.ToString

Finally

SR.Close()

EndTryEndFunction


I got almost 90% working. Some how my CSS stlyesheet are not working when send via email.

Include your styles in the HTML, not as separate files.

Jeff


They are included inside html.

Internall user dont see CSS effect in theri outlook but I tried to send it to my yahoo mail and it worked fine. how can i make that work for outlook users?


is your CSS an external link?
remember that viewing HTML mail is an option that can be turned off ( I have it turned off in my outlook express)
it would probably help to see some code...

It would also help to see the rendered source of a message from your outlook, so we can determine if it's not getting there the way it should.

From inside outlook, open the message (not in your preview pane) and then right click somewhere inside the message body and choose "View Source"

Copy and paste a short version of the mail message your trying to send.