Formatting an email in VBA‏

Lloydlobo

New Member
Joined
May 19, 2014
Messages
34
I have the following code which creates an email after selecting cells in Excel.
The Email defaults to Font Calibri 12.
If I want to make B17 bold and B28 in Calibiri 8, how do I incorporate within the code?


Many thanks,

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Sub Create_Individual_Email()
'Sending email to individual partners
Dim OutApp As Object
Dim OutMail As Object
Dim strbody As String

Sheets("Message").Visible = True
Sheets("Message").Select
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

On Error Resume Next
With OutMail
.To = "" & Range("B2").Value & ""
.Subject = "" & Range("b4").Value & vbNewLine
.Body = "" & Range("b6").Value & vbNewLine & _
"" & vbNewLine & _
"" & Range("b8").Value & vbNewLine & _
"" & Range("b10").Value & vbNewLine & _
"" & vbNewLine & _
"" & Range("b12").Value & vbNewLine & _
"" & vbNewLine & _
"" & vbNewLine & _
"" & Range("b14").Value & vbNewLine & _
"" & Range("b15").Value & vbNewLine & _
"" & vbNewLine & _
"" & vbNewLine & _
"" & Range("b17").Value & "," & vbNewLine & _
"" & Range("b18").Value & "," & vbNewLine & _
"" & Range("B19").Value & vbNewLine & _
"" & Range("B20").Value & vbNewLine & _
"" & Range("B21").Value & vbNewLine & _
"" & Range("B22").Value & vbNewLine & _
"" & Range("B23").Value & vbNewLine & _
"" & Range("B24").Value & vbNewLine & _
"" & Range("B25").Value & vbNewLine & _
"" & Range("B26").Value & vbNewLine & _
"" & vbNewLine & _
"" & Range("B28").Value & vbNewLine


'You can add a file like this
.Attachments.Add "" & Range("b30").Value & ""
.Attachments.Add "" & Range("b31").Value & ""
'.Send 'or use .Display
.Display
End With
On Error GoTo 0

Sheets("Message").Visible = False
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
 
Smart Indenter

happy user said:
When writing my own code I usually do it manually but Smart Indenter is useful when looking at other people's, badly/not indented code.

Also useful to tidy things up.

You can get it here.
 
Upvote 0

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Forum statistics

Threads
1,216,018
Messages
6,128,307
Members
449,439
Latest member
laurenwydo

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