|
-
Nov 27th, 2002, 03:52 PM
#1
Thread Starter
New Member
Email activedocument as attachment to Outlook
How would I go about attaching an active document to an email? Is this even possible?
-
Nov 28th, 2002, 05:33 AM
#2
Frenzied Member
When you say "active document" do you mean that the document is open in Word?
And you want to e-mail it using Outlook (not Outlook Express)?
You do know that there is a menu option in Word to do that?
If you want to do it by code from VB, then one way is:
You need to Save As the document to a new document, then send the new document, then Save As back to the original...
(Don't forget the references needed for Word).
VB Code:
Dim Obj
Dim OrigFullFile, TempFile As String
Set Obj = Word.ActiveDocument
If Obj.Saved = False Then Obj.Save
OrigFullFile = Obj.FullName
TempFile = Environ("Temp") & "\Document.DOC"
Obj.SaveAs TempFile
' Now SaveAs back to the original name to unlock the temporary document
Obj.SaveAs OrigFullFile
Then you can e-mail the attachment using Outlook:
VB Code:
'Reference Microsoft Outlook 9.0 Object Library (msoutl9.olb)
Private Sub Email_Click()
Dim olapp As New Outlook.Application
Dim olMail As Outlook.MailItem
Dim myAttachment As Outlook.Attachments
'Create a new mail object form the
'Outlook98 Application object
Set olMail = olapp.CreateItem(olMailItem)
Set myAttachment = olMail.Attachments
myAttachment.Add "C:\text.txt"
olMail.Subject = “Testing a send of a message”
olMail.Body = "Hello, this is the body"
olMailsend
Set olMail = Nothing
Set olapp = Nothing
End Sub
-
Nov 28th, 2002, 10:16 AM
#3
Thread Starter
New Member
Thank you...
I apologize for the lack of information. Yes, I know that this is an option in the File drop down menu but, this is actually for a form that will have a command button placed on it so that it automatically sends a copy of the active/open document/form to a group of recipients based on a field's selection.
I know. Too much information this time, right. Please forgive. I'm new to the forum.
-
Dec 27th, 2007, 07:54 AM
#4
New Member
Re: Email activedocument as attachment to Outlook
This is the exact same thing I'm looking for help on...
I have a command button on a form in Word that is acting as a Submit button. I have it so that when it is clicked it attaches the document to an Outlook mail message, but I am looking for help to figure out to get my email address put in as the recipient address because people are going to be sending it back to me.
The code I have for the command button right now is this:
Private Sub CommandButton1_Click()
Application.Options.ButtonFieldClicks = 1
Options.SendMailAttach = True
ActiveDocument.SendMail
End Sub
Anyone help with this would be greatly appreciated.
-Joe
-
Dec 27th, 2007, 10:15 AM
#5
Re: Email activedocument as attachment to Outlook
Here is the other thread from yesterday that is exactly the same need.
http://vbforums.com/showthread.php?t=502190
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|