Export Outlook custom forms fields to excel

Status
Not open for further replies.

newoay

New Member
Outlook version
Outlook 2007
Email Account
Exchange Server
Hi all,

I have a created a Custom Form in Outlook and would like to populate the fields to Excel. I am expecting to receive many such Custom Form emails so to automate the fields to populate to Excel would really help alot.
upload_2015-10-13_18-32-26.png

They are Listbox1, Listbox2, and Combobox1 respectively.
I've obtained a sample VBA code online that allows me to do the same to other fields but I've no idea how to utilise it to populate Custom Form fields. The code is below.

OptionExplicit
'This Code is Downloaded from OfficeTricks.com
'Visit this site for more such Free Code
Sub Download_Outlook_Mail_To_Excel()
'Add Tools->References->"Microsoft Outlook nn.n Object Library"
'nn.n varies as per our Outlook Installation
Dim Folder As Outlook.MAPIFolder
Dim sFolders As Outlook.MAPIFolder
Dim iRow AsInteger, oRow AsInteger
Dim MailBoxName AsString, Pst_Folder_Name AsString

'Mailbox or PST Main Folder Name (As how it is displayed in your Outlook Session)
MailBoxName = "MailBox Name"
'Mailbox Folder or PST Folder Name (As how it is displayed in your Outlook Session)
Pst_Folder_Name = "Folder Name"'Sample "Inbox" or "Sent Items"
'To directly a Folder at a high level
'Set Folder = Outlook.Session.Folders(MailBoxName).Folders(Pst_Folder_Name)

'To access a main folder or a subfolder (level-1)
ForEach Folder In Outlook.Session.Folders(MailBoxName).Folders
If VBA.UCase(Folder.Name) = VBA.UCase(Pst_Folder_Name) ThenGoTo Label_Folder_Found
ForEach sFolders In Folder.Folders
If VBA.UCase(sFolders.Name) = VBA.UCase(Pst_Folder_Name) Then
Set Folder = sFolders
GoTo Label_Folder_Found
EndIf
Next sFolders
Next Folder
Label_Folder_Found:
If Folder.Name = ""Then
MsgBox "Invalid Data in Input"
GoTo End_Lbl1:
EndIf
'Read Through each Mail and export the details to Excel for Email Archival
ThisWorkbook.Sheets(1).Activate
Folder.Items.Sort "Received"

'Insert Column Headers
ThisWorkbook.Sheets(1).Cells(1, 1) = "Sender"
ThisWorkbook.Sheets(1).Cells(1, 2) = "Subject"
ThisWorkbook.Sheets(1).Cells(1, 3) = "Date"
ThisWorkbook.Sheets(1).Cells(1, 4) = "Size"
ThisWorkbook.Sheets(1).Cells(1, 5) = "EmailID"
'ThisWorkbook.Sheets(1).Cells(1, 6) = "Body"

'Export eMail Data from PST Folder
oRow = 1
For iRow = 1 To Folder.Items.Count
'If condition to import mails received in last 60 days
'To import all emails, comment or remove this IF condition
If VBA.DateValue(VBA.Now) - VBA.DateValue(Folder.Items.Item(iRow).ReceivedTime) <= 60 Then
oRow = oRow + 1
ThisWorkbook.Sheets(1).Cells(oRow, 1).Select
ThisWorkbook.Sheets(1).Cells(oRow, 1) = Folder.Items.Item(iRow).SenderName
ThisWorkbook.Sheets(1).Cells(oRow, 2) = Folder.Items.Item(iRow).Subject
ThisWorkbook.Sheets(1).Cells(oRow, 3) = Folder.Items.Item(iRow).ReceivedTime
ThisWorkbook.Sheets(1).Cells(oRow, 4) = Folder.Items.Item(iRow).Size
ThisWorkbook.Sheets(1).Cells(oRow, 5) = Folder.Items.Item(iRow).SenderEmailAddress
'ThisWorkbook.Sheets(1).Cells(oRow, 6) = Folder.Items.Item(iRow).Body
EndIf
Next iRow
MsgBox "Outlook Mails Extracted to Excel"
Set Folder = Nothing
Set sFolders = Nothing

End_Lbl1:
EndSub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
O Export Outlook calendar appointments by filters and date range Outlook VBA and Custom Forms 1
J Export Zimbra to Outlook PST Using Outlook.com accounts in Outlook 1
C Export NSF Lotus Notes files in Outlook PST format? Using Outlook 1
C How to export Outlook data to csv? Using Outlook 0
T How to Export mailbox from Outlook 2019 to MBOX format? Using Outlook 1
R How To Repair OST File & Export OST File to Outlook PST ? Using Outlook 3
J Copy or Export Outlook Mail to Excel Outlook VBA and Custom Forms 6
Diane Poremsky Export (Save) Outlook Contact photos New Slipstick.com Articles 0
W macro to export outlook emails to excel Outlook VBA and Custom Forms 6
Q Outlook 2016\365 export specific rules to import in another system Exchange Server Administration 1
H How to export *all* fields from Outlook Using Outlook 2
M Outlook 2013/365 won't export 99% of my contacts to csv Using Outlook 2
T Outlook 2007 Export tasks to Excel Using Outlook 2
Sarge USMC Cannot import/export Outlook 13 Using Outlook 6
L Outlook 2007 Codes Export and Import Using Outlook 9
L Outlook 2007 Toolbar Export and Import Using Outlook 7
F Export Outlook contacts by One Category Using Outlook 1
M outlook shared calendar data export to excel sheet Using Outlook 1
O Export (save) Outlook Contact photos Using Outlook 2
D Export Outlook Calendar Using Outlook 1
C Outlook 200? - Script Export Rules Using Outlook 1
K outlook 2007 Export/Import Distribution lists Using Outlook 1
P Cannot export contacts with Outlook 2003 Using Outlook 10
C outlook export to excel in real time Using Outlook 3
S How can I export or print a list of all my folder names in Outlook? Using Outlook 1
D Outlook 2003, Export to CSV, "Export From' blank Using Outlook 5
V Launching Access export from Outlook task, Access Password pop-up window gets lost Using Outlook 1
B can not export contact file microsoft outlook 2002 Using Outlook 2
B Re: Export/Import/Switch from WLM to Outlook Using Outlook 1
B Export from Outlook Express and Windows Live Mail fails to copy to Outlook 2010 Using Outlook 1
R is import and export engine available in outlook 2010 trial version? Using Outlook 2
D cannot import contact files to outlook 2003, cannot change import and export applications and tools, Using Outlook 3
H Export address fields from outlook Using Outlook 2
D How can I export a .pst file without a working copy of Outlook? Using Outlook 3
G Trial Outlook 2010 Export email and contact Records to Outlook 2003 Using Outlook 1
D export contacts from outlook Using Outlook 2
W Windows XP/Outlook 2003: Can I export my Outlook contact list to a web based email account at the server. How can I configure CSV format to comply wit Using Outlook 1
K How do I save my outlook calendar to a csv format if the only choice i am given when trying to export it is ics? Using Outlook 1
L Keeping Outlook contact, documents and favourites from trial programs installed. cant access these files to export them. Using Outlook 2
F outlook 2010 beta email export Using Outlook 7
W can't export Outlook 2007 mail after trial Using Outlook 2
Y Export Outlook contacts to Windows Contacts in Windows 7 Using Outlook 3
D export contacts in Outlook 2003 using Windows 7 - no folders Using Outlook 10
M Why msg files are differ after export from Outlook to filesystem? Outlook VBA and Custom Forms 4
R Export email from Outlook into Access... Outlook VBA and Custom Forms 3
K Disabling import/export button to restrict PST creation Using Outlook 3
K Export Folder to PST Outlook VBA and Custom Forms 2
R Outlook 2010 How do you export 2 email Accounts' 2010 Inbox Files to new computer (2019)? Using Outlook 0
M Export-Import .pst file problems Using Outlook 2
M How to export Voting Results with user names and their responses Outlook VBA and Custom Forms 13

Similar threads

Top