+ Reply to Thread
Results 1 to 3 of 3

receive email in format html from Outlook

  1. #1
    Registered User
    Join Date
    12-12-2013
    Location
    Milan, Italy
    MS-Off Ver
    Excel 2007 -2010
    Posts
    24

    receive email in format html from Outlook

    Hello

    I would like to ask you, I tried to search in Google but i have find this code and change name of file and sheet. But not function, I think that I have to write the error of code?
    Sorry I am not very expert of VBA and I am studying.


    Const xlUp As Long = -4162

    Sub ExportToExcel(MyMail As MailItem)
    Dim strID As String, olNS As Outlook.NameSpace
    Dim olMail As Outlook.MailItem
    Dim StrBody As String
    Dim strFileName As String

    '~~> Excel Variables
    Dim oXLApp As Object, oXLwb As Object, oXLws As Object
    Dim lRow As Long

    strID = MyMail.EntryID
    Set olNS = Application.GetNamespace("MAPI")
    Set olMail = olNS.GetItemFromID(strID)

    '~~> Establish an EXCEL application object
    On Error Resume Next
    Set oXLApp = GetObject(, "Excel.Application")

    '~~> If not found then create new instance
    If Err.Number <> 0 Then
    Set oXLApp = CreateObject("Excel.Application")
    End If
    Err.Clear
    On Error GoTo 0

    '~~> Show Excel
    oXLApp.Visible = True

    '~~> Open the relevant file
    Set oXLwb = oXLApp.Workbooks.Open("D:\Profili\xxxxxx\Desktop\xxxxx.xlsm")

    '~~> Set the relevant output sheet. Change as applicable
    Set oXLws = oXLwb.Sheets("AAAAAA")

    lRow = oXLws.Range("A" & oXLApp.Rows.Count).End(xlUp).row + 1

    '~~> Write to outlook
    With oXLws
    '
    '~~> Code here to output data from email to Excel File
    '~~> For example

    .Range("A" & lRow).Value = olMail.Subject
    .Range("B" & lRow).Value = olMail.SenderName
    .Range("C" & lRow).Value = olMail.ReceivedTime
    .Range("D" & lRow).Value = olMail.HtmlBody


    olMail.HtmlBody = StrBody

    "<td style="padding-right: 7px; padding-left: 7px;"> 12/09/2015 12:30:00</td>"&
    "<td style="padding-right: 7px; padding-left: 7px;">Court</td>"& _
    "<td style="padding-right: 7px; padding-left: 7px;">Number</td>"& _
    "<td style="padding-right: 7px; padding-left: 7px;">Players</td>"& _
    "<td style="padding-right: 7px; padding-left: 7px;">Name</td>"& _
    "<td style="padding-right: 7px; padding-left: 7px;">Fullname</td>"& _
    "<td id="yui_3_16_0_1_1442210929051_2289" style="padding-right: 7px; padding-left: 7px;">Age</td>"& _
    "<td style="padding-right: 7px; padding-left: 7px;">Country</td>"& _
    "<td style="padding-right: 7px; padding-left: 7px;">Time</td>"& _



    End With

    '~~> Close and Clean up Excel
    oXLwb.Close (True)
    oXLApp.Quit
    Set oXLws = Nothing
    Set oXLwb = Nothing
    Set oXLApp = Nothing

    Set olMail = Nothing
    Set olNS = Nothing
    End Sub


    Give me the error :-(
    I hope that you will help me to solve it.
    Thanks.

    Davide

  2. #2
    Registered User
    Join Date
    12-12-2013
    Location
    Milan, Italy
    MS-Off Ver
    Excel 2007 -2010
    Posts
    24

    Re: receive email in format html from Outlook

    sorry i mean to convert from email html in text

  3. #3
    Registered User
    Join Date
    12-12-2013
    Location
    Milan, Italy
    MS-Off Ver
    Excel 2007 -2010
    Posts
    24

    Re: receive email in format html from Outlook

    so somebody does not know how? or very complicate?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] HTML email into strings for use in Outlook
    By rmachbitz in forum Excel Programming / VBA / Macros
    Replies: 28
    Last Post: 09-01-2015, 04:32 PM
  2. Replies: 9
    Last Post: 11-06-2014, 10:43 AM
  3. Using HTML Body Format in Outlook mail
    By akash kothari in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-08-2014, 11:33 AM
  4. excel to outlook email in HTML
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-29-2014, 05:34 AM
  5. [SOLVED] Userform HTML email format help needed please
    By Twaddy006 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 04-20-2014, 02:05 PM
  6. Macro to send saved draft email from outlook in HTML format
    By jamesshakedown in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-18-2013, 07:55 AM
  7. How to parse data in Outlook email using HTML version of email back to excel
    By bnasty in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 10-31-2012, 02:54 PM

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1