Carriage Returns

Posted on 2005-04-07
Last Modified: 2010-05-02

Trying to put some carriage returns in an email I'm generating using MAPI in VB6 (kind of new to this, so forgive me if it's an easy one). Basically the email is being generated the way a normal email would, however I need to take this:

Date: nnnnnnn  Time: nnnnnn  Submitted by: xxxxx  Approved by: xxxxx

and make it this:

Submitted by
Approved by

The fields are being populated by textbox values on the form and also a combobox.

Any info is appreciated.

Question by:celcius233
    LVL 53

    Accepted Solution

    YourString = "Date: " & textbox.text & vbcrlf
    youstring = yourstring & "Time: " & textbox.text & vbcrlf
    youstring = yourstring & "Submitted by: " & combobox.value & vbcrlf
    youstring = yourstring & "Approved by: " & textbox.text

    Remark: replace the textbox.text and combobox.value by the appropriate values
    LVL 10

    Expert Comment

    Hi, celcius233.

    What I've done is put a large, multiline "txtAll" textbox at the bottom of my form.  It grabs all the values of the other textboxes as follows:

         txtAll.Text = Textbox1 & vbNewLine & Textbox2 & vbNewline

    Where Textbox1 = "Date: nnnnnnn", Textbox2 = "Time: nnnnnn", etc.

    I'm auto-populating Outlook emails via code, so I need to replace vbNewline with HTML <br> tags; not sure if Mapi is the same.  I use the following string to populate my email's olMail.Body:

         Dim strTotalofTextboxes as String
         strTotalofTextboxes = Replace(txtAll.Text, vbNewLine, "<br>")

    This works on a string like: Date:nnnnnnn  Time:nnnnnn  Submitted by:xxxxx  Approved by:xxxxx

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
    When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now