objMailItem options

SteveSage

New Member
Joined
Sep 24, 2008
Messages
1
I've been using an inherited excel macro to generate a email using objMailItem and have worked out the basics, but am struggling to put in place some changes that will allow the macro to do things a little better.
Currently I have the following :

With objMailItem
.To = tolist
.Cc = cclist
.Subject = Subject
.body = sMsg
.attachments.Add filenamepath, 1
.Display
End With

So the enhancements i amm trying to do are :
a) the mail has to go in rich text format, but is there any way to set the format of each line in the ".body";
b) if I wanted to add some additional text after the attachment, how do I do this (adding a 2nd .body after the attachment does not seem to work); and
c) how do I add multiple attachments (rather than just the 1)

Appreciate any help
Thanks
Steve
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,278
Office Version
  1. 365
Platform
  1. Windows
Steve

a) There is no 'rich text' format. Perhaps you mean HTML format? If so use HTMLBody instead of just Body.

b) Don't quite know what you mean there.:eek:

c) Just repeat attachments.Add

PS This is all assuming you are using Outlook.:)
 

RoryA

MrExcel MVP, Moderator
Joined
May 2, 2008
Messages
36,692
Office Version
  1. 365
  2. 2019
  3. 2016
  4. 2010
Platform
  1. Windows
  2. MacOS
Outlook can use rich text format but I think in order to do it you have to actually create the rtf string including formatting codes and then pass that to the body property. As far as I know, you have no control over where the attachments end up, but you could try setting the Body, adding an attachment, then set the Body = Body & newtext and so on.
 

Watch MrExcel Video

Forum statistics

Threads
1,129,271
Messages
5,635,215
Members
416,847
Latest member
inaramos

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
Top