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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SendMailAttach + Subject 1

Status
Not open for further replies.

Molenski

IS-IT--Management
Jan 24, 2002
288
DE
Hi there,

Just wondering if anyone can help. Am trying to create a macro in Word 97 that will simply attach the document you are working on to an Outlook 98 email message with a subject line and a name in the 'To' field but doesn't actually send it.

I am using the...

Options.SendMailAttach = True
ActiveDocument.SendMail

...as opposed to the Routing Slip method but I can't seem to work out how to get a subject line and a name in the 'To' field.

Can someone please help or I'm going to eat my own arms off.

Thanks a lot.

Molenski
As my bessie bud Kev always says - "Get involved!!!"
 
Try this code, I'm not too sure if it will work in Office '97 though, but it's worth a try.

Code:
Sub Send_Email()
' Be Sure to set a reference to MS Outlook before using this procedure.
' Go to Tools->References and select the Outlook library from the list and press OK.
Dim newOL As New Outlook.Application
Dim newMail As MailItem
Set newOL = New Outlook.Application
Set newMail = newOL.CreateItem(olMailItem)
With newMail
    .To = "noone@nowhere.com"
    .Subject = "This is a Test"
    .Body = "This is a test Email sent to you from Excel. " & _
        "Please, do not reply to this Email."
    .Display ' This will display the Email for editing
    ' .Send ' This will send the Email directly
End With
Set newMail = Nothing
Set newOL = Nothing
End Sub

I hope this works! And I hope this helps!

Good Luck!



Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Hi Mike,

Thanks for getting back......not sure what you mean by this....'select the Outlook Library'.

I only have a reference to the 'MS Outlook Object Model' in Tools/References.

Could you let me know if I'm just being a dummy!!!!!!

Thanks again.

Molenski
As my bessie bud Kev always says - "Get involved!!!"
 
Mike, have sorted it and it works great.

Thanks a lot for your help - youve got a star!!!

Molenski
As my bessie bud Kev always says - "Get involved!!!"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top