agill


I want to be able to automatically attach a MS Word protected form and email from within Word. Need the email address, subject line and attachment to be done automaically, and will have to turn document protection off and then back on after email has been sent.

Help! This is what I have so far...

Sub SavenEmail()
ActiveDocument.SaveAs FileName:= _
"4-7 3-2 New_Change Product Request Rev3.doc", FileFormat:= _
wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _False, SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
Application.Run MacroName:="EmailSend"
Application.Run MacroName:="EmailMessageOptions"
End Sub




Re: Email Form from MS Word

Shasur


Please check if the following link leads to a solution

http://vbadud.blogspot.com/2007/04/vba-email-automation-vba-mail.html

Cheers

shasur







Re: Email Form from MS Word

agill

This information was helpful, but for Excel and Outlook. I need Word and Outlook. I am now trying to use this code - only problem is that I am getting a "User-defined type not defined" error message. How do I fix this


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 "Please choose the directory to save your document."
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 = "ProductRequest@JB.com"
.Subject = "New/Product Request Form"
.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






Re: Email Form from MS Word

Shasur

Are you sure that you have added

Microsoft Outlook 9.0 Object Library to your project.. If not please add it through Tools Menu-->References

Hope it works

Cheers

Shasur