Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Body text To Sendmail command

Status
Not open for further replies.

simeybt

Programmer
Nov 3, 2003
147
GB
All,

Is there way of adding body text to an e-mail you are sending using the snedmail command in excel

Simon
 
Hi,

You can use this kind of sending routine to add a message text:

Sub Testsend()

ActiveWorkbook.HasRoutingSlip = True
With ActiveWorkbook.RoutingSlip

.Recipients = Array("name1", "name2", "etc")
.Subject = "Test"
.Message = "Hello this is a test message"
End With

ActiveWorkbook.Route

End Sub

Is that what you're after?
 
I have been playing around with that but it adds extra text at the bottom of the message saying "The attached document has a routing slip ... etc ". Do you know how to get rid this text
 
You can use

.ReturnWhenDone = False

in the With Statement, so it won't be able to be routed elsewhere but still gives you the message

"The enclosed document has a routing slip. You are the last recipient; no further routing is necessary."

I can't find any other options to suppress this currently, but I'll keep looking.

Nic
 
Simon,

You could perhaps try looking at controlling Outlook through Excel. I've come across a few articles relating to Sendmail but they all say you can't add Message text.

Have a look at the following article:


Unfortunately I haven't got time at the moment to write a simpler version of what's in this article.

I used this method a few years ago and it's fairly flexible as you can either specify the recipients you want in the code or choose from your Address Book.

best of luck

Nic
 
looks good nic but being Friday evening i can't be bothered to start playing around with it now. I’ll give it a try next week.
Thanks
Simon
 
I think the sort answer to your question is "no," you can't add body text with the .sendmail command. That having been said, there are other methods of sending mail.

I'm actually having a similar problem right now. I don't have any extra text at the bottom of the email - so that problem is eliminated - but I'm having trouble with the syntax to add the current workbook. (BTW, this is for GroupWise, but I'm sure it can be tweeked for Outlook.) Here's what I have so far:
Code:
    With New GroupwareTypeLibrary.Application
        With .Login
            With .MailBox.Messages.Add(Class:="GW.MESSAGE.MAIL")
            .Subject.PlainText = "Subject"
            .Bodytext.PlainText = "This is a test"
            .Recipients.Add array(recipient1, recipient2)
            .Send
            End With
        End With
        .Quit
    End With

My problem is trying to use .Attachments.Add to attach the current workbook. The arguments for this are (vr, kind, displayname), but I don't even know what "vr" stands for.

I don't mean to hijack your thread, simeybt, but I figured that if this bit can be worked out it might help you!
 
Not sure if this will help but I use the following code. It takes the range and inserts it into body of the email as HTML so it keeps all the formating.

Public Sub Email()

Dim olApp As Outlook.Application
Dim olMail As Outlook.MailItem
Dim FSObj As Scripting.FileSystemObject
Dim TStream As Scripting.TextStream
Dim rngeSend As Range
Dim strHTMLBody As String


'Select the range to be sent
Set rngeSend = Application.Range("B1:G35")
If rngeSend Is Nothing Then Exit Sub 'User pressed Cancel
On Error GoTo 0

'Now create the HTML file
ActiveWorkbook.PublishObjects.Add(xlSourceRange, "C:\sales\tempsht.htm", rngeSend.Parent.Name, rngeSend.Address, xlHtmlStatic).Publish True


'Create an instance of Outlook (or use existing instance if it already exists
Set olApp = CreateObject("Outlook.Application")

'Create a mail item
Set olMail = olApp.CreateItem(olMailItem)

'Open the HTML file using the FilesystemObject into a TextStream object
Set FSObj = New Scripting.FileSystemObject
Set TStream = FSObj.OpenTextFile("C:\sales\tempsht.htm", ForReading)

'Now set the HTMLBody property of the message to the text contained in the TextStream object
strHTMLBody = TStream.ReadAll

olMail.HTMLBody = strHTMLBody
olMail.To = "anybody@anywhere.com"
olMail.Subject = "Email Subject"
olMail.Send
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top