A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - General Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Send Saved Word Doc as attachment to fixed email address



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old June 2nd 08, 05:51 AM posted to microsoft.public.outlook
Jules[_2_]
external usenet poster
 
Posts: 2
Default Send Saved Word Doc as attachment to fixed email address

Hi VBA to send Word document to Outlook 2007 and prior without opening
Outlook. Code I have still wants to open Outlook before it sends it from
Outbox?

Option Explicit
Sub SendDocumentAsAttachment()

Dim bStarted As Boolean
Dim oOutlookApp As Outlook.Application
Dim oItem As Outlook.MailItem

On Error Resume Next

If Len(ActiveDocument.Path) = 0 Then
MsgBox "Document needs to be saved first"
Exit Sub
End If

Set oOutlookApp = GetObject(, "Outlook.Application")
If Err 0 Then
Set oOutlookApp = CreateObject("Outlook.Application")
bStarted = True
End If

Set oItem = oOutlookApp.CreateItem(olMailItem)

With oItem
.To = "
.Subject = "New 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"
.Send
End With

If bStarted Then
oOutlookApp.Quit
End If

Set oItem = Nothing
Set oOutlookApp = Nothing

End Sub



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Send Word doc attachment Chris Outlook and VBA 3 May 20th 08 04:41 PM
I can send email with attachment receiver cannot open attachment saffi Outlook - General Queries 8 December 5th 07 10:06 AM
why my Excel attachment to email opens with Word? AJ Outlook - General Queries 3 August 23rd 06 07:08 PM
Auto BCC to a fixed address Proboscis Outlook and VBA 2 July 19th 06 08:36 AM
Cannot change default Insert Attachment folder- FIXED Cooler Dude Outlook Express 0 March 5th 06 11:16 AM


All times are GMT +1. The time now is 12:51 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.