is it possible to create a button in Outlook that when pressed can extract information about the selected emails headers + body? Where abouts can i start looking?
Basic info im trying to obtain automatically is:
From
Subject
Body
If you are using outlook 2000 then the following code will work. I have tested this on my machine running Outlook 2000 and it runs just fine.
Sub GetSelectedItem_Click()
' This uses an existing instance if available (default Outlook behavior).
Dim oApp As New Outlook.Application
Dim oExp As Outlook.Explorer
Dim oSel As Outlook.Selection ' You need a selection object for getting the selection.
Dim oItem As MailItem
Set oExp = oApp.ActiveExplorer ' Get the ActiveExplorer.
Set oSel = oExp.Selection ' Get the selection.
For i = 1 To oSel.Count ' Loop through all the currently .selected items
Set oItem = oSel.Item(i) ' Get a selected item.
MsgBox (oItem.SenderName & vbcrlf & oItem.subject & vbcrlf & oItem.Body) ' Display information about it.
Next i
End Sub
thats great, yeah im using Outlook 2000. Where abouts do i stick that code though? Ive never experimented with this before. Do you have a good tutorial link i could look at?
(Its saved as VBAProject.otm - is there anyway to save that else where?)
Is there anyway to stop outlook from saying "An application is trying to access your emails!"? Its most annoying having to say allow access for 10minutes.
As far as the storage of the macro goes you have got it stored in the best place.
The messages you are getting are more of a problem but there should be a workaround. You should take a look at thread707-620926 for a possible work around.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.