How to capture selected email's: subject, date, sending person to variable

pitaszek

Board Regular
Joined
Jul 20, 2012
Messages
85
Hello Community,

I would like to know how to operate on Outlook objects.

I need to highlight an email and retrieve it's basic details like: subject, who is the sender, date etc.

Then ideally forward the values to a form where I will be able to select another attributes (specified by me) and send to Excel.

Hope you can give me some examples.

Cheers,
W
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hello

This example code goes in Outlook module:


Code:
Sub Outlook_to_Excel()
Dim xl As Object, mi As MailItem, wb, ws
Set mi = Application.ActiveInspector.CurrentItem
Set xl = CreateObject("Excel.Application")
xl.Visible = 1
Set wb = xl.Workbooks.Open("d:\pub\solver.xlsm")                ' your path here
Set ws = wb.sheets("sheet1")
With mi
    If TypeName(mi) = "MailItem" Then
        ws.[b25] = .SenderEmailAddress                          ' transfer to Excel
        ws.[b26] = .Subject
        ws.[b27] = .ReceivedTime
        ws.[b28] = .SentOn
        ws.[b29] = .Importance
    End If
End With
Set ws = Nothing: Set wb = Nothing
Set xl = Nothing: Set mi = Nothing
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,965
Messages
6,122,500
Members
449,090
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top