# Copy all Contents from Word Document in same format to outlook Email Body



## kshitij_dch (Feb 5, 2021)

Hello All,
I am working on a macro which will Copy all Contents from Word Document in same format to outlook Email Body ,I have managed to get a code which is pasting data from excel as string only but not in a same format of word  , any chance if i can get it in exact format that of word document ???


```
Sub SendDocAsMsg()
    Dim wd As Word.Application
    Dim doc As Word.Document
    Dim oOutlookApp As Outlook.Application
    Dim oItem As Outlook.MailItem
    
    On Error Resume Next
    'Start Outlook if it isn't running
    Set oOutlookApp = GetObject(, "Outlook.Application")
    If Err <> 0 Then
        Set oOutlookApp = CreateObject("Outlook.Application")
    End If
    On Error GoTo 0
    
    Set wd = CreateObject("Word.Application")
    
    wd.Visible = True
    
    Set doc = wd.Documents.Open(Filename:="C:\Users\Sony\Desktop\Document.docx", ReadOnly:=True)
    
    'Copy the open document
    doc.Content.Select
    Word.Selection.Copy
    
    Set oItem = oOutlookApp.CreateItem(olMailItem)
    With oItem
        .To = "this@email.com"
        .Subject = "Kshitij Sharma"
        .Body = Word.Selection
        .Display
    End With
    
    doc.Close
    wd.Quit
    
    Set doc = Nothing
    Set oItem = Nothing
    Set oOutlookApp = Nothing
    Set wd = Nothing
End Sub
```
??


----------



## daverunt (Feb 5, 2021)

See if this will help









						How to send a Word document as body of an email with VBA
					

I've created a macro that works with outlook and excel that will use a list of email addresses (in excel) and send all those addresses an email (in outlook). I want to take a word document (from




					stackoverflow.com


----------



## kshitij_dch (Feb 5, 2021)

daverunt said:


> See if this will help
> 
> 
> 
> ...


Hello Dave

I have checked this piece of Code from the above URL however not working 


```
Sub emailFromDoc()
    Dim wd As Object, editor As Object
    Dim doc As Object
    Dim oMail As MailItem

    Set wd = CreateObject("Word.Application")
    Set doc = wd.documents.Open(...path to your doc...)
    doc.Content.Copy
    doc.Close
    set wd = Nothing

    Set oMail = Application.CreateItem(olMailItem)
    With oMail
        .BodyFormat = olFormatRichText
        Set editor = .GetInspector.WordEditor
        editor.Content.Paste
        .Display
    End With
End Sub
```

i am getting error on "Set oMail = Application.CreateItem(olMailItem)" Error : Object dosen't support this property or method , can you help in this ??


----------



## Macropod (Feb 5, 2021)

Do note that the only way to truly replicate the document layout in your email is to attach it; emails don't support headers, footer, footnotes, endnotes and a myriad of other features found in typical Word documents. Moreover, you have no control over any pagination features, or where images etc. will end up, etc. when viewed by the recipient.


----------



## daverunt (Feb 8, 2021)

Replace:


```
Set oMail = Application.CreateItem(olMailItem)
with
     Set OutApp = CreateObject("Outlook.Application")
     Set oMail = OutApp.CreateItem(0)
```


----------

