VBA email body, including If statements

neilsolaris

New Member
Joined
Feb 5, 2015
Messages
7
Hi,

I wrote some code previously that sends individual emails according to data in an Excel file. It all works well, but I'd like to insert an If statement, in order to replace "Hi" with "Good morning / Good afternoon / Good evening" depending on the time of day.

The problem I have is this. Let's say that I start with setting the email body as "Good morning " (if it's morning). Then when the code resumes, it overwrites the "Good morning " with the remaining email.

So my question is, how can I write the code in such as way so that I can resume the email body from where I've left off? I don't know if my question is clear or not. If not I can attach some code if necessary.

Many thanks for your help.
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
I think I may have found the solution now on another thread. I create the whole email as a string, and when the string is complete then set it to the email body. Does that sound correct?
 
Upvote 0

Forum statistics

Threads
1,213,506
Messages
6,114,024
Members
448,543
Latest member
MartinLarkin

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