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!

send word document via macro 1

Status
Not open for further replies.

mrmovie

Technical User
Oct 2, 2002
3,094
GB
I want to send a document as an attachment to a list of people.
Excels SendMail method has 3 possible parameters

email list
subject
and one other but cant remember what it is

words sendmail method doesnt have any parameters?

i have tried

ActiveDocument.HasRoutingSlip = True
With ActiveDocument.RoutingSlip
.Subject = "New subject goes here"
.AddRecipient "richard.moyle@fujitsu-siemens.com"
'.AddRecipient "Secondaddress@Mail.com"
.Delivery = wdAllAtOnce
End With
ActiveDocument.Route

which works but i dont like the warning messages word gives me about someone trying to send an email etc.

i have vbscripts to send email but these dont work from within the actual word document because it complains that the file i am trying to attach is in use,,,naturally.

any other methods i can use???

cheers
von moyla
 
If you set a reference to the Outlook Library in your project and enter the following code (and modify it), you can send any file as an attachment in Outlook:

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."
    .Attachments.Add Source:="EnterPath_And_FileName"
    .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 helps!



Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
thanks for the post. solves the issue with the attachment being open which is cool, thanks. still get a horrid, "someone is trying to access your email,,do you wish to allow this,," not to worry they will have to click on the send button themselves.
have a star
von moyla
 
You could try,

Code:
Application.DisplayAlerts = False
Code:
'  The Email Code
Code:
Application.DisplayAlerts = True

To try to stop the message, but I don't believe it is a Word message.

I'm glad it worked for you (The email code!)

[cheers]



Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top