|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
String wierdness...use the following code to generate the body of the email: tmpBody += vbCrLf tmpBody += "----- " & SupTechs.Item(j) & " (" & tmpCount & " servers monitored) -----" tmpBody += vbCrLf tmpBody += <Specific Server Error Message> However, I get emails that sometimes have the linebreak before the Specific Server Error Message, and some that don't. Here's a sample email: ----- npl2bjl (1 servers monitored) ----- NEOMASVR0000 (Daily Backup): Canceled by NEOMASVR0000\US\R05D53BESvc,Error - Mount failed. User canceled a Physical Volume Library operation. Why is there no linebreak between "-----" and "NEOMASVR0000"? When I look at the email in a hex editor, it's just a space. Some of the emails look correct, such as: ----- neb1jwg (3 servers monitored) ----- NECOLSVR0005 (W Drive): Failed,Storage device "COMPAQ 1" reported an error on a request to write data to media.Error reported:Data error (cyclic redundancy check). Warning - A severe error occurred while reading or writing data. This job may not have been successfully completed.Robotic Library: Drive: COMPAQ 1Slot: A communications failure has occurred between the Backup Exec job engine and the remote agent. Any ideas? *** Sent via Developersdex http://www.developersdex.com *** Not sure this will help with your problem, but I would rewrite your code like
this: tmpBody = vbCrLf tmpBody &= "----- " & SupTechs.Item(j) & " (" & tmpCount & " servers monitored) -----" tmpBody &= vbCrLf tmpBody &= <Specific Server Error Message> When dealing with Strings it's good practice to avoid "+" and use "&" instead since the former is an arithmetic operator which can cause problems when there are numbers in your string. Show quoteHide quote "Terry Olsen" <tolse***@hotmail.com> wrote in message news:OzZwnNlhGHA.3424@TK2MSFTNGP05.phx.gbl... >I send out a daily email to technicians regarding nightly backup logs. I > use the following code to generate the body of the email: > > tmpBody += vbCrLf > tmpBody += "----- " & SupTechs.Item(j) & " (" & tmpCount & " servers > monitored) -----" > tmpBody += vbCrLf > tmpBody += <Specific Server Error Message> > > However, I get emails that sometimes have the linebreak before the > Specific Server Error Message, and some that don't. Here's a sample > email: > > ----- npl2bjl (1 servers monitored) ----- NEOMASVR0000 (Daily Backup): > Canceled by NEOMASVR0000\US\R05D53BESvc,Error - Mount failed. User > canceled a Physical Volume Library operation. > > Why is there no linebreak between "-----" and "NEOMASVR0000"? When I > look at the email in a hex editor, it's just a space. Some of the emails > look correct, such as: > > ----- neb1jwg (3 servers monitored) ----- > NECOLSVR0005 (W Drive): Failed,Storage device "COMPAQ 1" reported an > error on a request to write data to media.Error reported:Data error > (cyclic redundancy check). Warning - A severe error occurred while > reading or writing data. This job may not have been successfully > completed.Robotic Library: Drive: COMPAQ 1Slot: A communications > failure has occurred between the Backup Exec job engine and the remote > agent. > > Any ideas? > > *** Sent via Developersdex http://www.developersdex.com ***
Show quote
Hide quote
"Terry Olsen" <tolse***@hotmail.com> wrote in message I would use String.Format :)news:OzZwnNlhGHA.3424@TK2MSFTNGP05.phx.gbl... >I send out a daily email to technicians regarding nightly backup logs. I > use the following code to generate the body of the email: > > tmpBody += vbCrLf > tmpBody += "----- " & SupTechs.Item(j) & " (" & tmpCount & " servers > monitored) -----" > tmpBody += vbCrLf > tmpBody += <Specific Server Error Message> > > However, I get emails that sometimes have the linebreak before the > Specific Server Error Message, and some that don't. Here's a sample > email: > Const BODY_FORMAT As String = _ vbNewLine & "----- {0} ({1} server{2} monitored) -----" & _ vbNewLine & "{3}" Dim tmpBody As String = String.Format( _ BODY_FORMAT, _ SupTechs.Item(j), _ tmpCount, _ IIf(tmpCount = 1, String.Empty, "s"), _ <specific server error message here> _ ) HTH :0 Mythran
Show quote
Hide quote
"Terry Olsen" <tolse***@hotmail.com> wrote in message Oh, and I forgot to mention, it seems like your email viewer may be news:OzZwnNlhGHA.3424@TK2MSFTNGP05.phx.gbl... >I send out a daily email to technicians regarding nightly backup logs. I > use the following code to generate the body of the email: > > tmpBody += vbCrLf > tmpBody += "----- " & SupTechs.Item(j) & " (" & tmpCount & " servers > monitored) -----" > tmpBody += vbCrLf > tmpBody += <Specific Server Error Message> > > However, I get emails that sometimes have the linebreak before the > Specific Server Error Message, and some that don't. Here's a sample > email: > > ----- npl2bjl (1 servers monitored) ----- NEOMASVR0000 (Daily Backup): > Canceled by NEOMASVR0000\US\R05D53BESvc,Error - Mount failed. User > canceled a Physical Volume Library operation. > > Why is there no linebreak between "-----" and "NEOMASVR0000"? When I > look at the email in a hex editor, it's just a space. Some of the emails > look correct, such as: > > ----- neb1jwg (3 servers monitored) ----- > NECOLSVR0005 (W Drive): Failed,Storage device "COMPAQ 1" reported an > error on a request to write data to media.Error reported:Data error > (cyclic redundancy check). Warning - A severe error occurred while > reading or writing data. This job may not have been successfully > completed.Robotic Library: Drive: COMPAQ 1Slot: A communications > failure has occurred between the Backup Exec job engine and the remote > agent. > > Any ideas? > > *** Sent via Developersdex http://www.developersdex.com *** translating the text as html, therefore removing carriage-returns and linefeeds. Are you setting the body format type to text, specifically? HTH again, Mythran > Oh, and I forgot to mention, it seems like your email viewer may be Yes, I figured it out. Outlook was "removing extra linefeeds in plain-text > translating the text as html, therefore removing carriage-returns and > linefeeds. Are you setting the body format type to text, specifically? messages." I cleared that and everything looks fine. But I do appreciate the pointers about the strings. Would a StringWriter or StringBuilder be a better choice? For that matter, what's the difference between the two? Terry,
The first thing to do is in my idea taking the advice of Mike Lowery. With Option Strict of your code as now can give very unpredictable results. Cor Show quoteHide quote "Terry Olsen" <tolse***@hotmail.com> schreef in bericht news:OjE2$wshGHA.4404@TK2MSFTNGP05.phx.gbl... >> Oh, and I forgot to mention, it seems like your email viewer may be >> translating the text as html, therefore removing carriage-returns and >> linefeeds. Are you setting the body format type to text, specifically? > > Yes, I figured it out. Outlook was "removing extra linefeeds in > plain-text messages." I cleared that and everything looks fine. But I do > appreciate the pointers about the strings. Would a StringWriter or > StringBuilder be a better choice? For that matter, what's the difference > between the two? > Terry Olsen wrote:
>> Oh, and I forgot to mention, it seems like your email viewer may be A StringBuilder would be the better choise.>> translating the text as html, therefore removing carriage-returns and >> linefeeds. Are you setting the body format type to text, specifically? > > Yes, I figured it out. Outlook was "removing extra linefeeds in plain-text > messages." I cleared that and everything looks fine. But I do appreciate > the pointers about the strings. Would a StringWriter or StringBuilder be a > better choice? For that matter, what's the difference between the two? > > A StringBuilder is used to put together a string without making new copies of the string for each operation. The += operator might give the impression that a string is added at the end of an existing string, but that is not so. Strings in .NET are immutable, e.g. they can not be changed. The += operator concatenates the strings into a new string, and the reference to the new string replaces the original string. For a few short strings the += operator works fine, but the larger the string grows, the more data has to be copied for each operation. You should use a StringBuilder when there are more than a few strings, and always if you don't know beforehand how many strings there will be. A StringWriter is a TextWriter wrapper around a StringBuilder. One specific advantage of the StringWriter is when you write different data types to it. You can specify a culture when you create the StringWriter, and that cuture is then used to convert things like numbers and dates to strings when you write them to the StringWriter. When you do the same using a StringBuilder, it always uses the default culture, or you have to specify the culture for each value you add using the AppendFormat method. Terry,
The Stringbuilder (a mutable string (collection) of char objects) would give you in your problem probably not any advantage. For that are the strings to short. A stringwriter gives you the oppurtinity to write whatever to a string instead of to a file or a stream. http://www.vb-tips.com/default.aspx?ID=06d9730e-9e33-404c-947a-c891846eaf0b I hope this gives some direct answers on your latest question. Cor Show quoteHide quote "Terry Olsen" <tolse***@hotmail.com> schreef in bericht news:OjE2$wshGHA.4404@TK2MSFTNGP05.phx.gbl... >> Oh, and I forgot to mention, it seems like your email viewer may be >> translating the text as html, therefore removing carriage-returns and >> linefeeds. Are you setting the body format type to text, specifically? > > Yes, I figured it out. Outlook was "removing extra linefeeds in > plain-text messages." I cleared that and everything looks fine. But I do > appreciate the pointers about the strings. Would a StringWriter or > StringBuilder be a better choice? For that matter, what's the difference > between the two? >
Calling VB.Net classes from VB6
Data base insert Error HELP! Adding a row to a table help! Is there a Forms collection? Why doesn't changing the position in a table change the position of the DatGridView that's bound to How to measure bandwidth need by the application Converting Code from VBA to VB.NET Is RegEx a good choice for reading malformed xml? Crypto removing white spaces from byte array Ambiguous in the Namespace |
|||||||||||||||||||||||