Results 1 to 12 of 12

Thread: Text Bold in VB

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2014
    Posts
    2

    Text Bold in VB

    Hi All,

    I have to make the bold letters in the below mentioned code. Here the word " Invitation " should be bold and made as blue color. How can I do it?


    Sub Test1()
    'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
    'Working in Office 2000-2013
    Dim OutApp As Object
    Dim OutMail As Object
    Dim cell As Range

    Application.ScreenUpdating = False
    Set OutApp = CreateObject("Outlook.Application")

    On Error GoTo cleanup
    For Each cell In Columns("B").Cells.SpecialCells(xlCellTypeConstants)
    If cell.Value Like "?*@?*.?*" And _
    LCase(Cells(cell.Row, "C").Value) = "yes" Then

    Set OutMail = OutApp.CreateItem(0)
    On Error Resume Next
    With OutMail
    .to = cell.Value
    .Subject = "Invitation"
    .Body = "Hello, " & vbNewLine & vbNewLine & _
    "Invitation " & vbNewLine & vbNewLine & _
    "Warm Regards," & vbNewLine & _
    "Annie Antone"







    'You can add files also like this
    '.Attachments.Add ("C:\test.txt")
    .Send 'Or use Display
    End With
    On Error GoTo 0
    Set OutMail = Nothing
    End If
    Next cell

    cleanup:
    Set OutApp = Nothing
    Application.ScreenUpdating = True
    End Sub

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    8,601

    Re: Text Bold in VB

    Looks like code to send an email. I believe most email clients can render HTML so try bolding tags:-
    Code:
    Subject = "<b>Invitation</b>"
    I'm just taking a stab in the dark here. I've never done anything with email as a developer so I don't really know.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2014
    Posts
    2

    Re: Text Bold in VB

    No it is not coming in bold.

  4. #4

  5. #5
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,543

    Re: Text Bold in VB

    It depends on both the sender and receiving client... the sender has to make sure the text is marked up properly by either sending the correct HTML or RTF. It then also depends on the receiving client being able to render the HTML/RTF that was sent.

    In this case, setting the .Body only sets the basic plain text part of the message. In order to send the HTML, you'll want to set the HTMLBody property (Ithink that's the right one) and set the .IsHTML (again, I think that's right) to True, so it knows there's two parts and can be rendered in the client, if it supports it.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,543

    Re: Text Bold in VB

    Oh... wait... are we talking about the subject line? or the Body of the message? I assumed we were talking about the message... I don't think ANY client supports HTML or any markup in the Subject line... at least I haven't seen one that did.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Text Bold in VB

    Quote Originally Posted by techgnome View Post
    Oh... wait... are we talking about the subject line? or the Body of the message? I assumed we were talking about the message... I don't think ANY client supports HTML or any markup in the Subject line... at least I haven't seen one that did.

    -tg
    Yep, the subject line. The only client I have seen that do this kind of formatting is browser based.

  8. #8
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: Text Bold in VB

    In any case this isn't a VB6 question but an Office Automation question.

    The issues are the same whether you use VB6, VBA, VBScript, Visual FoxPro, Visual Fred, or just about anything else supporting COM Automation.

    Wrong forum.

  9. #9
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,543

    Re: Text Bold in VB

    I guess I was asking how did we get to the conclusion it was the subject line? I see "Invitation" twice in the code... once in the subject line, and one in the body, which is where I apparently gravitated towards. I didn't even see the subject line initially... but that might be because usually when these requests come in, it's about the body.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  10. #10
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: Text Bold in VB

    Quote Originally Posted by techgnome View Post
    I guess I was asking how did we get to the conclusion it was the subject line?
    I guess this could be the answer, TG.
    Quote Originally Posted by sathishkm View Post
    Hi All,
    ... Here the word " Invitation " should be bold and made as blue color. How can I do it?

    ...
    With OutMail
    .to = cell.Value
    .Subject = "Invitation"
    .Body = "Hello, " & vbNewLine & vbNewLine & _

  11. #11
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,543

    Re: Text Bold in VB

    Yeah, I see that NOW...

    but it's also in the Body:
    Code:
    .Body = "Hello, " & vbNewLine & vbNewLine & _
    "Invitation " & vbNewLine & vbNewLine & _
    Guess we'll never know since it appears that the OP has pulled a disappearing act on us.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  12. #12
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    9,177

    Re: Text Bold in VB

    I think he went to study up on Visual Fred.

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