Underline, Bold part of sentence

josros60

Registered User.
Local time
Today, 10:44
Joined
Mar 10, 2011
Messages
73
I have this code,

How can i Underline and bold just part of the message,


Here it's the code:

Code:
sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "advise us if you would prefer to wire us payment to our [U][B][COLOR="Red"]updated SVB USD Bank account [/COLOR][/B][/U]shown on the invoice, or if we may collect the payment from  your Wallet account. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"


Thanks.
 
If you're using Outlook automation, you can use HTML tags and HTML body.
 
thanks.

I am new in vba, just learning, can you show me, please.

thanks
 
This would bold the name:

sBody = "Hi <b>" & Me.txtFirstName & "</b>," & vbCrLf & vbCrLf & "Here is the m..."

I think you'd also have to switch from vbCrLf to <br>.
 
I tried but doesn't do it:

is it possible if put the code below, you can show me there where to put the <b> in the sentence, the one want to put bold and underline is in red, thansk.

Code:
sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "advise us if you would prefer to wire us payment to our updated [U][B][COLOR="Red"]SVB USD Bank[/COLOR][/B][/U] account shown on the invoice, or if we may collect the payment from  your Wallet account. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"
 
where are you showing this textbox, msgbox, outlook?
 
This is code is in Microsoft access, and there's a button send, when i click opens outlook and that's the body message.

so I want to underline and bold this sentence "updated SVB USD"

thanks
 
use pbaldy's suggestion and also use MailItem.HTMLBody = sBody.
 
I tried but doesn't do it:

is it possible if put the code below, you can show me there where to put the <b> in the sentence, the one want to put bold and underline is in red, thansk.

What exactly did you try? How do you use the body string? Look up HTML tags. Put them where you want them. This starts the bold <b>, this ends it </b>. The HTML tags go inside the strings with your text.
 
Tried the way suggested below,

Code:
sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "advise us if you would prefer to wire us payment to our updated <b> SVB USD Bank </b> account shown on the invoice, or if we may collect the payment from  your Wallet account. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"

when goes to outllook,

this is what get:

sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "advise us if you would prefer to wire us payment to our updated <b> SVB USD Bank </b> account shown on the invoice, or if we may collect the payment from your Wallet account. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"

and add this line,

Code:
 MailItem.HTMLBody = sBody

and i get run-time error 424 and hightlight the line above.

thanks
 
What's the whole procedure? I suspect you're just copying in bits that don't fit what you're doing.
 
This is the whole procedure:

Code:
Private Sub btnSend_Click()
Dim oApp As New Outlook.Application
Dim oEmail As Outlook.MailItem
Dim sBody As String
Set oEmail = oApp.CreateItem(olMailItem)
    
If IsNull(Me.txtTo) Then                     ' No email address
MsgBox "Please Select a Customer, if the email field is empty, then edit the customer and add the email by clicking the Edit Customer button at the bottom!", vbOKOnly, "Add the Email address"  ' Tell user
Me.txtCompany.SetFocus ' Focus the control
Exit Sub
 Else
 oEmail.To = Me.txtTo
 oEmail.CC = Me.txtCCEmail & ";" & Me.txtCCEmail2
 oEmail.BCC = "ar@hyperwallet.com"
 End If
 
                                   ' Exit the method
If txtSubject > 0 Then
oEmail.Subject = Me.txtSubject
Else
oEmail.Subject = Me.txtCompany.Column(1) & " " & "-" & "  " & "Invoice #"
End If
  
If Me.txtBody > 0 Then
'If Len(Me.txtBody & vbNullString) > 0 Then
sBody = Me.txtBody


ElseIf Forms![Contact Details]![Auto Collect] = True Then
 
sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & " As per your instructions we will withdraw the amount from your loading wallet.  " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"

Else
 
sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "advise us if you would prefer to wire us payment to our updated <b> SVB USD Bank </b> account shown on the invoice, or if we may collect the payment from  your Wallet account. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"
 
 
 
 'sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "Please confirm if we may collect the payment from your wallet. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"
    
   End If
   If Len(Me.txtAttachment) > 0 Then
        oEmail.Attachments.Add Me.txtAttachment.Value
        
    End If
 
   With oEmail
      '  If Not IsNull(.To) And Not IsNull(.subject) And Not IsNull(.Body) Then
          .SentOnBehalfOfName = "AR@HYPERWALLET.COM"
          .Display
            'MsgBox "Remember to attach Invoice(s)", vbOKOnly, "Attach Invoice(s)"
       End With
      
       
    
    
    'oEmail.Body =
   MailItem.HTMLBody = sBody
      
   oEmail.Body = sBody
   
End Sub

thanks
 
You'd have to use your variable:

oEmail.HTMLBody = sBody
 
The issue is the vbCrLf's in the HTML

Replace them with <p>

eg
sBody = "Hi" & " " & Me.txtFirstName & ", <p>......
 
I tried your suggestion but I get error,

when <p>, and when put oEmail.HTMLBody = sBody said variable not defined.

Would you please write for me the whole line of this code the way it should be, and I paste it into the code:

sBody = "Hi" & " " & Me.txtFirstName & ", <p>...

thanks so much, i have trying difference ways never get it to work.
 
Starting with this

Code:
sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "advise us if you would prefer to wire us payment to our updated <b> SVB USD Bank </b> account shown on the invoice, or if we may collect the payment from  your Wallet account. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"
As I said, replace vbCrLf's with <p>

Code:
sBody = "Hi" & " " & Me.txtFirstName & ", [COLOR=Red]<p>[/COLOR] Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "advise us if you would prefer to wire us payment to our updated <b> SVB USD Bank </b> account shown on the invoice, or if we may collect the payment from  your Wallet account. [COLOR=Red]<p>[/COLOR] Please contact me if you have any questions.Thanks,"
There's any number of web sites that will give you information on constructing HTML, including having italics, different fonts/colors/sizes, including tables/pictures. That's what I do, search for required html formatting, create a string that renders as I want it in my browser, then construct it in vba with the data fed in from the database.
 

Users who are viewing this thread

Back
Top Bottom