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
 

Some videos you may like

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
75,530
Office Version
365
Platform
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
34,793
Office Version
365, 2019, 2016, 2010
Platform
Windows, 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,095,201
Messages
5,443,002
Members
405,212
Latest member
Arnie58

This Week's Hot Topics

  • Copy entire row if CountA <>0 to another sheet
    [B]I want to copy entire row if CountA <>0 for column J7:AM7 (headers on J6:AM6) and so on till the last used cell is column D and paste the...
  • Select last used Row in Table
    I have created a Table in a Worksheet which is locked to prevent user errors and protect formula. Some of the cells require freetext entries which...
  • excel workbook: do not allow certain file name
    Hello all, Don't think this has ever been asked before, but how do I restrict file save [Before_Save Event] if the name of the file being saved...
  • fixing problem autofilter
    hello i need help about my code when i search by code in textbox it doesn't show anything this is my data [ATTACH type="full"...
  • “Weight”
    Hi, i’ve got a long sheet filled with weights such as kg,g,L & ml. i can build a formula to convert kg into g and liter into ml. How ever, my...
  • How to capitalize everything before a certain character?
    In column A, I have some text: Hello good day.mp3 Hello good day.flac etc. I'd like to capitalize everything before the period. I don't need the...
Top