dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Alignment in Email

  1. #1
    Join Date
    Jan 2013
    Posts
    55

    Alignment in Email

    I'm sending emails from VB6 project.
    I'm concatenating values to build the body of the email message like this:
    Code:
                    strBody = "Feedback for the Job #: " & txtJobNumber.Text & vbNewLine & _
                        "Job Name: " & txtJobName.Text & vbNewLine & _
                        "Sent By: " & strUserName & vbNewLine & vbNewLine & _
                        "Feedback: " & txtFeedback.Text & vbNewLine & vbNewLine & _
                        strListOfProjectTypes & _
                        strListOfBidders & strEngineer
    In debug mode I check the contents of strBody variable and Project Types part is aligned perfect, exactly as I want:
    Code:
    Project Types:
         Cook                	Basis Of Design       		$52,100.00
         Samsung             	                      		$80,200.00
         Airedale            	Modine MUA            		$112,100.00
         Armstrong Pumps     	Taco                  		$13,000.00
         Danfoss             	                      		$34,000.00
         Berner              	Basis Of Design       		$8,950.00
         Misc.               	Modine UH amd CUH     		$52,700.00
         Redd-i              	                      		$1,300.00
    When the receiver get's an email and opens it either in Outlook or in IE or Chrome, the alignment is broken. Something like this:
    Code:
    Project Types:
         Cook                           Basis Of Design             $52,100.00
         Samsung                                                        $80,200.00
         Airedale                      Modine MUA                  $112,100.00
         Armstrong Pumps        Taco                             $13,000.00
         Danfoss                                                          $34,000.00
         Berner                        Basis Of Design              $8,950.00
         Misc.                           Modine UH amd CUH      $52,700.00
         Redd-i                                                             $1,300.00
    What would you suggest to do to keep alignment?

    Thank you

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    12,740

    Re: Alignment in Email

    Use a fix width font. Determine the length of each column entry in each row and pad with spaces as appropriate before adding them to the string.

    So assuming that the 1st column should have a width of 35, the 'cook' entry would get padded with 31 spaces, the 'Samsung' entry gets padded with 28 spaces, and so on.

    In addition, you'll want to left and right trim whitespace from your string variables as well. Whitespace at the beginning or end of the string variables can mess with your formatting - so trim it off.
    Last edited by Arjay; June 22nd, 2018 at 10:52 PM.

  3. #3
    Join Date
    Jan 2013
    Posts
    55

    Re: Alignment in Email

    Thank you

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)