Results 1 to 4 of 4

Thread: Outlook message into a Word document

  1. #1
    Join Date
    May 2009
    Posts
    40

    Outlook message into a Word document

    I am having some doubt in Outlook 2007 whenever i get any emails and if i like it then i usually copy paste the content and then store it in Word. But i was thinking there would be some way to copy and paste or drag and drop and Outlook message into a Word document. When i asked my friends about the same they told me that it's not possible. Can anyone make some comments on it .

  2. #2
    Join Date
    Jan 2009
    Posts
    150

    Outlook message into a Word document

    In that case you need to create RTF format email where this is would be very messy code for you to understand but i am sure with this your work will be done.

    Code:
    Sub PrintCustomMessageFormat()
    'Modification to Outlook 2003 Inside Out Code sample
    
    'Set up objects
        Dim str_Template As String
        Dim objWord As Word.Application
        Dim objDocs As Word.Documents
        Dim obj_WordDocEditor As Word.Document
        Dim mybklist As Word.Bookmarks
    
        Dim objApp As Application
        Dim objItem As MailItem
        Dim objFolder As MAPIFolder 'WP
        Dim objNS As NameSpace
    
        Dim folderName As String
        Dim strAttachments As String
        'Create a Word document and current message item object
        Set objApp = CreateObject("Outlook.Application")
    
        Set objNS = objApp.GetNamespace("MAPI")
        'Check to ensure Outlook item is selected
    
        If TypeName(objApp.ActiveInspector) = "Nothing" Then
            MsgBox "Message not open. Exiting", vbOKOnly + vbInformation,
    "Outlook Inside Out"
            Exit Sub
        End If
    
    
        Set objItem = objApp.ActiveInspector.CurrentItem
        'WP:  Add to get current folder
        Set objFolder = objApp.ActiveExplorer.CurrentFolder
    
    
        folderName = objFolder.FolderPath
        If objItem.Attachments.Count <> 0 Then
            For Each Attachment In objItem.Attachments
                    strAttachments = strAttachments + Attachment.FileName
    + vbCrLf
    
            Next
        End If
    
        Set objWord = CreateObject("Word.Application")
        str_Template = "r:\EmailCustomPrintFormat2.dot"
        Set objDocs = objWord.Documents
        objDocs.Add strTemplate
        Set mybklist = objWord.ActiveDocument.Bookmarks
        'Fill in the form
        objWord.ActiveDocument.Bookmarks("Subject").Select
        objWord.Selection.TypeText CStr(objItem.Subject)
    
        objWord.ActiveDocument.Bookmarks("From").Select
        objWord.Selection.TypeText CStr(objItem.SenderName)
        objWord.ActiveDocument.Bookmarks("DateSent").Select
        objWord.Selection.TypeText CStr(objItem.SentOn)
        objWord.ActiveDocument.Bookmarks("Received").Select
        objWord.Selection.TypeText CStr(objItem.ReceivedTime)
        objWord.ActiveDocument.Bookmarks("To").Select
        objWord.Selection.TypeText CStr(objItem.To)
    
        objWord.ActiveDocument.Bookmarks("folderName").Select
        objWord.Selection.TypeText CStr(folderName)
    
        objWord.ActiveDocument.Bookmarks("Attachments").Select
        objWord.Selection.TypeText strAttachments
    
        objWord.Visible = True
    
        If objItem.GetInspector.EditorType = olEditorWord Then
            Set obj_WordDocEditor = objItem.GetInspector.WordEditor
            objWordDocEditor.Range.Copy
            objWord.ActiveDocument.Bookmarks("Body").Select
            'objWord.ActiveDocument.Bookmarks("Body").Range.InsertAfter
    (vbCrLf)
            ' overwrites whole doc  objWord.ActiveDocument.Range.Paste
            objWord.Selection.Paste
            'objWord.Selection.FormattedText = objWordDocEditor.Range
        Else
            objWord.ActiveDocument.Bookmarks("Body").Select
            objWord.Selection.TypeText objItem.Body
    
        End If
    
    
        If MsgBox("Continue?", vbYesNo, "Continue") = vbYes Then
    
            'Print and exit
            objWord.PrintOut Background:=True
            'Process other system events until printing is finished
            While objWord.BackgroundPrintingStatus
                DoEvents
            Wend
        End If
    
        objWord.Quit SaveChanges:=wdvbaDoNotSaveChanges
    
        'WP additions
        Set objWord = Nothing
        Set objApp = Nothing
    
    End Sub

  3. #3
    Join Date
    May 2009
    Posts
    40

    Outlook message into a Word document

    I have try to use the above code but it's not working perfectly as i want to have it. Can any give me some idea where i can work around the code and get exactly what i need it because your code works but it is not accurate that's the only think in which i am having some problem or is there any other method to do it apart from coding. Thanks for replying me.

  4. #4
    Join Date
    Jan 2009
    Posts
    141

    Re: Outlook message into a Word document

    I don't thinks so that you can perform such kind of work because you don't have control over the way the sender or recipient sends/ reads your email, in that case if you really want it then you can accept it in unformatted text. If you want to dictate how you want to views the document, you probably should tell the user to send it as a .pdf file

Similar Threads

  1. Blank word document opens while opening original document
    By Loyalpalm in forum Windows Software
    Replies: 6
    Last Post: 02-12-2011, 12:27 AM
  2. Replies: 1
    Last Post: 10-06-2011, 03:31 AM
  3. Command line switch error message with the word document
    By Baby bon bon in forum Windows Software
    Replies: 5
    Last Post: 29-03-2011, 07:51 PM
  4. Replies: 6
    Last Post: 25-09-2010, 07:37 PM
  5. Converting Word 97-2003 document to Word 2007
    By Jerry in forum Vista Help
    Replies: 7
    Last Post: 19-05-2008, 03:14 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,234,955.18179 seconds with 17 queries