Apply Bold To Partial String

ir121973

Active Member
Joined
Feb 9, 2008
Messages
371
Hi, I wonder whether someone could help me please.

I'm using a script to send out a automated email which contains several lines of text.

One such line is as follows:

Code:
vbNewLine & vbNewLine & _"Please DO NOT copy the username and password from this email, but key them directly into the login page." & _

Could someone tell me please how I could bold text the wording DO NOT.

I've been researching this, but all of the information I've found relates to cell or comment values rather than text within the code itself.

Many thanks and kind regards

Chris
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
If you want to add formatting to the body of the e-mail then you'll need to get the .HTMLBody property of the message and not the .Body property. If you do that, however, you'll have to use "<p> ... </p>" or "<br/>" to generate new lines in your message. For example:

Code:
newMail.HTMLBody = "<br/><br/>Please <b>DO NOT</b> copy the username and password from this email, but key them directly into the login page."

If you're doing this then perhaps it's also a nice touch to provide a link to the login page using <a> tags around the word "login".

WBD
 
Last edited:
Upvote 0
Hi @wideboydixon, thank you for taking the time to come back to me with this and my apologies for not coming back to you sooner.

I wasn't able to get the solution working you kindly provided, but I found a post here: excel vba - Change HTML email body font type and size in VBA - Stack Overflow

Some of the issues I have is that part of the body of the text extract cell values, my apologies not making this clearer.

Here is the complete email text:

Code:
With OutMail
                .To = cell.Value
                .Subject = "Splunk Access"
                .Body = "Hi " & Cells(cell.Row, "A").Value _
                    & vbNewLine & vbNewLine & _
                        "I have been asked to create an account for you." & _
                    vbNewLine & vbNewLine & _
                        "Your username and password details are:" & _
                    vbNewLine & vbNewLine & _
                        "Username: " & Cells(cell.Row, "C").Value & _
                    vbNewLine & _
                        "Password: " & Cells(cell.Row, "I").Value & _
                    vbNewLine & vbNewLine & _
                        "Please DO NOT copy the username and password from this email, but key them directly into the login page." & _
                    vbNewLine & vbNewLine & _
                        "When you do log into your account, at your earliest convenience change your password to a more secure one." & _
                    vbNewLine & vbNewLine & _
                        "You can do this by clicking on your name on the top menu and select 'Edit Account'." & _
                    vbNewLine & vbNewLine & _
                        "You can use this link to get to the log in page for this environment: " & _
                    vbNewLine & vbNewLine & _
                        "PROD: https://...."

So I'm now trying to bring the two together.

Have you any ideas please?

Many thanks and kind regards

Chris
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,915
Members
452,366
Latest member
TePunaBloke

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top