Results 1 to 6 of 6

Thread: [RESOLVED] [2005] Advert

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Location
    Chicago, IL
    Posts
    514

    Resolved [RESOLVED] [2005] Advert

    Hello All,

    I've finished (pretty much), a nifty program for my company that sends out automated Advertisments that you set up using a template, some Items you select.

    It pulls the information from SQL Server 2000, and then writes an HTML file (based on the template - the template has tags in it, like <!!!!HEADER!!!!>, that I use a stringbuilder to replace with more HTML code around the data).

    Here is the problem - when I view the final HTML document that is going to be e-mailed, all comma's in the pulled data from SQL server are missing, so sentences run together. What is odder, is that commas in the footer HTML are fine (not pulled from SQL Server). Even odder still is some commas that I wrote myself directly in the template HTML file ARE also MISSING in the final one.

    Here is an idea of what it's doing:

    VB Code:
    1. For Y = 0 To Me.tblMfg_Prod_Desc.Rows.Count - 1
    2.     bodyString.AppendLine("<LI>" & Me.tblMfg_Prod_Desc.Rows(Y)("Mfg_Bullet") & "</LI>")
    3. Next Y

    That is where it's stripping out the commas. Why?
    Warren Ayen
    Senior C# Developer
    DLS Software Studios (http://www.dlssoftwarestudios.com/)

    I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
    Hey! If you like my post, or I solve your issue, please Rate Me!

  2. #2

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Location
    Chicago, IL
    Posts
    514

    Re: [2005] Advert

    Nevermind. It appears to be an issue with sending HTML e-mails, actually. The HTML document itself is fine.

    Okay, I'm using .NET 2.0. Here is my e-mail code. It loads the entire HTML document into a string, then replaces parts of that string with the header and footer strings (because each email goes to stores with Reps, we want each email to display rep info and so on when mailed). So if the HTML document is fine, that means it's f***ing up when it's mailing:

    VB Code:
    1. 'create message
    2. AdvertEmail.IsBodyHtml = True
    3. AdvertEmail.Body = strHTMLTemplateData
    4. AdvertEmail.Subject = tblAdvert_Header.Rows(X)("Advert_Description")
    5. AdvertEmail.From = AdvertEmailAddressesC.Item(2)
    6.  
    7. 'send the message
    8. oMsg.Send(AdvertEmail)

    Is the problem because I am loading the entire HTML document into a single string, then replacing parts of it? Do strings in VB 2005 erase commas?
    Warren Ayen
    Senior C# Developer
    DLS Software Studios (http://www.dlssoftwarestudios.com/)

    I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
    Hey! If you like my post, or I solve your issue, please Rate Me!

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Location
    Chicago, IL
    Posts
    514
    I think I know the issue, but I need help to fix it, please:

    I've never learned how to use the "streamreader" and so on, classes for File I/O. I know, go ahead, yell at me. I still use FileOpen() and Input().

    Buuuut, VB .NET from 2002 and up removes commas when bringing a string in, doesn't it?

    Please, tell me, how do I use a streamreader? What do I do? I don't understand why it has to be an array of bytes and so on. How does it work? What do I do to just load a file, the entire thing, into one string?
    Warren Ayen
    Senior C# Developer
    DLS Software Studios (http://www.dlssoftwarestudios.com/)

    I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
    Hey! If you like my post, or I solve your issue, please Rate Me!

  4. #4
    Hyperactive Member kayos's Avatar
    Join Date
    Apr 2004
    Location
    Largo, Florida
    Posts
    306

    Re: [2005] Advert

    if it is 2005 like you say, you should try using the "My" namespace for file interaction.

    VB Code:
    1. My.Computer.FileSystem.*

    another tip, you get the StreamReader and StreamWriter classes with the System.IO namespace


    If this post helps, please RATE MY POST!

    Using Visual Studio 2005 SE

  5. #5

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Location
    Chicago, IL
    Posts
    514

    Re: [2005] Advert

    Yes, I know where the classes are. What my issue is, I have no idea how to use them...they confuse me. I need to get this done today and I was hoping someone knew a snippet of code to simply pull in an entire file to one string...I'll keep trying...
    Warren Ayen
    Senior C# Developer
    DLS Software Studios (http://www.dlssoftwarestudios.com/)

    I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
    Hey! If you like my post, or I solve your issue, please Rate Me!

  6. #6

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2006
    Location
    Chicago, IL
    Posts
    514
    Figured it out

    VB Code:
    1. Dim newFileStream As System.IO.FileStream
    2.         Dim bytesRead(1024) As Byte
    3.         Dim byteConvert As New System.Text.UTF8Encoding
    4.  
    5.         newFileStream = New System.IO.FileStream("C:\42.html", IO.FileMode.Open)
    6.  
    7.  
    8.         Do While newFileStream.Read(bytesRead, 0, 1024)
    9.             Me.RichTextBox1.Text = Me.RichTextBox1.Text & byteConvert.GetString(bytesRead, 0, 1024)
    10.  
    11.         Loop
    Warren Ayen
    Senior C# Developer
    DLS Software Studios (http://www.dlssoftwarestudios.com/)

    I use Microsoft Visual Studio 2005, 2008, working with Visual Basic and Visual C#
    Hey! If you like my post, or I solve your issue, please Rate Me!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width