Use VBA to set Email Background Colour (1 Viewer)

randallst

Registered User.
Local time
Today, 21:11
Joined
Jan 28, 2015
Messages
64
Hi Everybody,

It's been a good while since posting on here, but hoping someone might be able to help with my following question, or if it is even possible haha!

Is it possible to apply a email background colour using VBA?

My current coding that works for the general message is the following;

Code:
Private Sub EmailNotification_Click()

Dim cc As String
Dim bcc As String
Dim mailto As String

mailto = "email address here"
'cc = ""
'bcc = ""

mailsub = "New Incident Created: " & Me.Incident_ID & ""

emailmsg = "Incident ID: " & Me.Incident_ID & vbNewLine & "Category: " & Me.Category & vbNewLine & "Title: " & Me.Title & vbNewLine & vbNewLine & "Please liaise with the Engineering Team for further information in relation to the above incident"

On Error Resume Next
End Sub

Any help offered would be greatly appreciated.

All the best
Stuart
 

Isaac

Lifelong Learner
Local time
Today, 13:11
Joined
Mar 14, 2017
Messages
8,778
You might be able to manipulate the vba object MailItem's .htmlbody property

I don't know a lot about HTML, but here is one method I successfully used to create emails full of html (without knowing anything about html!) ....
1. Create an email that looks exactly like I want it to.
2. View Source and store the html in a table or in a text file
3. Use Placeholder bits of text for the variables
4. At run-time, read in the text and replace the placeholders as appropriate, assigning the htmlbody property of the mailitem.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:11
Joined
Oct 29, 2018
Messages
21,494
Hi Stuart. The first question is, what is your email client application? For instance, are you using Outlook?
 

randallst

Registered User.
Local time
Today, 21:11
Joined
Jan 28, 2015
Messages
64
Hi Stuart. The first question is, what is your email client application? For instance, are you using Outlook?

Hi There,

I am using Outlook as part of Office 365.

All the best
Stuart
 

randallst

Registered User.
Local time
Today, 21:11
Joined
Jan 28, 2015
Messages
64
You might be able to manipulate the vba object MailItem's .htmlbody property

I don't know a lot about HTML, but here is one method I successfully used to create emails full of html (without knowing anything about html!) ....
1. Create an email that looks exactly like I want it to.
2. View Source and store the html in a table or in a text file
3. Use Placeholder bits of text for the variables
4. At run-time, read in the text and replace the placeholders as appropriate, assigning the htmlbody property of the mailitem.

Hi There,

Thanks for the advice, I will have a nosey at .htmlbody. I have no experience in this so this will be interesting haha!

All the best
Stuart
 

Isaac

Lifelong Learner
Local time
Today, 13:11
Joined
Mar 14, 2017
Messages
8,778
Using that method I have been able to do a lot of nice emails with no html knowledge.
This site looks to cover it pretty well. You basically just declare and set a MailItem, assign its BodyFormat as olFormatHTML, and then assign the .HTMLBody as [whatever text source - variable etc - your HTML is]
Hope it works well for you.
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:11
Joined
Oct 29, 2018
Messages
21,494
Hi There,

I am using Outlook as part of Office 365.

All the best
Stuart
By that, you mean a desktop client version, right? Not the one at outlook.office365.com, correct?
 

randallst

Registered User.
Local time
Today, 21:11
Joined
Jan 28, 2015
Messages
64
By that, you mean a desktop client version, right? Not the one at outlook.office365.com, correct?
Yes the Desktop Application. Apologies I do forget there's a lot of web based apps now ha-ha!
 

theDBguy

I’m here to help
Staff member
Local time
Today, 13:11
Joined
Oct 29, 2018
Messages
21,494
Yes the Desktop Application. Apologies I do forget there's a lot of web based apps now ha-ha!
Okay, that's good. In that case, you should be able to use what Isaac was talking about (i.e. use HTML tags). Good luck!
 

Users who are viewing this thread

Top Bottom