Good morning,
I have built a macro that generates an email from MS Outlook with predefined text, attachments, addressees, and buttons that link to a website. I currently have html code mingled with my vba, but I am wanting to have more stylish buttons and think I need to add in some CSS code. How is this done? Haven't been able to find any examples online. Is it even possible?
Here is the relevant part of my code. If it is possible to add CSS code, where would it go and how is it transitioned in?
Sub Correspondent()
Dim objOutlook As Object
Dim objMail As Object
Dim rngTo As Range
Dim rngSubject As Range
Dim rngBody As Range
Dim rngAttach As Range
Dim emailTo As String
Dim emailBody As String
Dim emailSubject As String
Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.CreateItem(0)
'emailTo = ""
'For Each cell In Range("CorrespondentRateSheet")
'If cell.Value <> "" Then emailTo = emailTo & cell.Value & ", "
'Next
emailBody1 = "<center><img src='O:\Departments\CUSO\TRUHOME SOLUTIONS\Business Development\Correspondent Lending\CL - Logo\TruHome_Correspondent Lending_horiz_logo.jpg' height='79' width='300'></center>" & "<br><br><br><br>" _
emailBody2 = "<center><strong><font size ='5' span style='color:#635245'>Thank You for Considering TruHome Solutions! Please See Today's Attached Price Indications. </font></strong></center>" & "<br><br><br><br>"
emailBody3 = "<center><table width='640' border='0' cellpadding='0' cellspacing='0'><tr><td><table width='300' border='0' cellspacing='0' cellpadding='10' align='left'><tr><td><p><center><table cellspacing='0' cellpadding='0'><tr><td align='center' width='175' height='40' bgcolor='#AABA0A' style='-webkit-border-radius: 25px; -moz-border-radius: 5px; border-radius: 5px; color: #ffffff; display: block;'><a href='http://www.truhomecorrespondent.com/' style='font-size:16px; font-weight: bold; font-family: Helvetica, Arial, sans-serif; text-decoration: none; line-height:40px; width:100%; display:inline-block'><span style='color: #FFFFFF'>Website/Portal</span></a></td></tr></table></td></tr></table><table width='300' border='0' cellspacing='0' cellpadding='10' align='right'>" _
& "<tr><td><p><center><table cellspacing='0' cellpadding='0'><tr><td align='center' width='175' height='40' bgcolor='#AABA0A' style='-webkit-border-radius: 25px; -moz-border-radius: 5px; border-radius: 5px; color: #ffffff; display: block;'><a href='https://1092859015.secure-onlineorigination.com/PrintableForm.aspx' style='font-size:16px; font-weight: bold; font-family: Helvetica, Arial, sans-serif; text-decoration: none; line-height:40px; width:100%; display:inline-block'><span style='color: #FFFFFF'>Forms</span></a></td></tr></table></center></p></td></tr></table></td></tr></table>" & "<br>" _
emailBody4 = "<center><table width='640' border='0' cellpadding='0' cellspacing='0'><tr><td><table width='300' border='0' cellspacing='0' cellpadding='10' align='left'><tr><td><p><center><table cellspacing='0' cellpadding='0'><tr><td align='center' width='175' height='40' bgcolor='#AABA0A' style='-webkit-border-radius: 25px; -moz-border-radius: 5px; border-radius: 5px; color: #ffffff; display: block;'><a href='http://www.truhomecorrespondent.com/PageContent.aspx?PageID=89' style='font-size:16px; font-weight: bold; font-family: Helvetica, Arial, sans-serif; text-decoration: none; line-height:40px; width:100%; display:inline-block'><span style='color: #FFFFFF'>Become A Client</span></a></td></tr></table></td></tr></table><table width='300' border='0' cellspacing='0' cellpadding='10' align='right'>" _
& "<tr><td><p><center><table cellspacing='0' cellpadding='0'><tr><td align='center' width='175' height='40' bgcolor='#AABA0A' style='-webkit-border-radius: 25px; -moz-border-radius: 5px; border-radius: 5px; color: #ffffff; display: block;'><a href='http://www.truhomecorrespondent.com/PageContent.aspx?PageID=75' style='font-size:16px; font-weight: bold; font-family: Helvetica, Arial, sans-serif; text-decoration: none; line-height:40px; width:100%; display:inline-block'><span style='color: #FFFFFF'>Products</span></a></td></tr></table></center></p></td></tr></table></td></tr></table>" & "<br>" _
emailBody5 = "<center><table width='640' border='0' cellpadding='0' cellspacing='0'><tr><td><table width='300' border='0' cellspacing='0' cellpadding='10' align='left'><tr><td><p><center><table cellspacing='0' cellpadding='0'><tr><td align='center' width='175' height='40' bgcolor='#AABA0A' style='-webkit-border-radius: 25px; -moz-border-radius: 5px; border-radius: 5px; color: #ffffff; display: block;'><a href='http://www.truhomecorrespondent.com/ContactUs.aspx' style='font-size:16px; font-weight: bold; font-family: Helvetica, Arial, sans-serif; text-decoration: none; line-height:40px; width:100%; display:inline-block'><span style='color: #FFFFFF'>Contact Us</span></a></td></tr></table></center></td></tr></table><table width='300' border='0' cellspacing='0' cellpadding='10' align='right'>" _
& "<tr><td><p><center><table cellspacing='0' cellpadding='0'><tr><td align='center' width='175' height='40' bgcolor='#AABA0A' style='-webkit-border-radius: 25px; -moz-border-radius: 5px; border-radius: 5px; color: #ffffff; display: block;'><a href='http://www.google.com' style='font-size:16px; font-weight: bold; font-family: Helvetica, Arial, sans-serif; text-decoration: none; line-height:40px; width:100%; display:inline-block'><span style='color: #FFFFFF'>Credit Overlays</span></a></td></tr></table></center></center></p></td></tr></table></td></tr></table>" & "<br>" _
emailBody6 = "<center><table width='640' border='0' cellpadding='0' cellspacing='0'><tr><td><table width='300' border='0' cellspacing='0' cellpadding='10' align='left'><tr><td><p><center>Column Left Content</td></tr></table><table width='300' border='0' cellspacing='0' cellpadding='10' align='right'><tr><td><p><center>Column Right Content</center></p></td></tr></table></td></tr></table>" & "<br><br>" _
'emailBody11 = "<center><table width='640' border='0' cellpadding='0' cellspacing='0'><tr><td><table width='300' border='0' cellspacing='0' cellpadding='10' align='left'><tr><td><p><center>Column Left Content</td></tr></table><table width='300' border='0' cellspacing='0' cellpadding='10' align='right'><tr><td><p><center>Column Right Content</center></p></td></tr></table></td></tr></table>" & "<br><br>" _
'emailBody12 = "<table cellspacing='0' cellpadding='0'><tr><td align='center' width='175' height='40' bgcolor='#000091' style='-webkit-border-radius: 25px; -moz-border-radius: 5px; border-radius: 5px; color: #ffffff; display: block;'><a href='http://www.google.com' style='font-size:16px; font-weight: bold; font-family: Helvetica, Arial, sans-serif; text-decoration: none; line-height:40px; width:100%; display:inline-block'><span style='color: #FFFFFF'>Credit Overlays</span></a></td></tr></table></center>" & "<br><br><br><br>"
emailBody7 = "<center><B><font size = '3'>TruHome Solutions, LLC</B></center>" & _
"<center><B><font size = '1'>(NMLS#284608)</B></center>" & _
"<center><font size = '2'>Correspondent Lock Desk</center>" & _
"<center><font size = '2'>9777 Ridge Drive, Lenexa KS 66219</center>" & _
"<center>Lock Desk Phone: (913)214-3556</center>" & _
"<center><A HREF =""[email protected]"">[email protected]</A></center>" & _
"<center>Lock Desk Hours: 9:00 am - 4:00 pm CST</center>" & "<br><br>" _
emailBody8 = "<center><img src='O:\Departments\CUSO\TRUHOME SOLUTIONS\Business Development\Correspondent Lending\CL - Logo\Equal Housing Lender Logo.jpg'></center>"
emailSubject = ""
For Each cell In Range("Correspondent_Subject")
If cell.Value <> "" Then emailSubject = emailSubject & cell.Value
Next
'With ActiveSheet
'Set rngAttach = .Range("B6")
'End With
With objMail
.to = ""
.Bcc = emailTo
.Subject = emailSubject
.HTMLbody = emailBody1 & emailBody2 & emailBody3 & emailBody4 & emailBody5 & emailBody6 & emailBody7 & emailBody8 & "<br>" & .HTMLbody
'.Attachments.Add rngAttach.Value
.Display 'Instead of .Display, you can use .Send to send the email _
or .Save to save a copy in the drafts folder
End With
Set objOutlook = Nothing
Set objMail = Nothing
Set rngTo = Nothing
Set rngSubject = Nothing
Set rngBody = Nothing
Set rngAttach = Nothing
End Sub
Bookmarks