mailing from word via Outlook

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When you mail a Word document via "Send to recipient", using Outlook for
mail, you generate a mail message, which just goes to your outbox when you
hit Send, but sits in your Outlook outbox until you actually open up Outlook.
Is there any way that anyone knows of to automatically Open up the Outlook
environment when you hit Send (or when you start the mail message), so that
the mail actually gets sent right away?
 
The following macro will open Outlook and send the current document as an
attachment, provided the above option to send mail immediately is set in
Outlook:

Sub Send_As_Mail_Attachment()

' send the document as an attachment _
in an Outlook Email message
Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem
Dim strName As String

strName = "<PR_EMAIL_ADDRESS>"
'Let the user choose the recipient in Outlook
strName = Application.GetAddress("", strName, _
False, 1, , , True, True)
If strName = "" Then
MsgBox "User cancelled or no name listed", , "Cancel"
Exit Sub
End If

On Error Resume Next

'Prompt the user to save the document
ActiveDocument.Save

'Get Outlook if it's running
Set oOutlookApp = GetObject(, "Outlook.Application")

'Outlook wasn't running, start it from code
If Err <> 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

'Create a new mailitem
Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
.To = strName
.Subject = "This is the subject"
'Add the document as an attachment, you can use the _
.displayname property
'to set the description that's used in the message
.Attachments.Add Source:=ActiveDocument.FullName, _
Type:=olByValue, DisplayName:="Document as attachment"
'.Display
.Body = "See attached document"
.Send
End With

'Clean up
Set oItem = Nothing
Set oOutlookApp = Nothing
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top