This is regarding Excel & Outlook 2013 -
I am working on a problem where I need to...
- Receive an email
- Have that email automatically moved to a specific folder
- Have any email in said folder exported into a .csv file
- The data in that file must be placed under specific columns.
I can achieve all of the above, except #4. The script places the entire body of the email in different cells depending on breakpoints.
Here's a copy of the email I need to export:
Area of Interest: Post a Job
Type of Job: Full-time
Campus Location: Montgomery
---------------------
Contact Information:
Title: Manager
Contact Last Name: Wilson
Contact First Name: Allison
Address: 3424 Peachtree Rd NE
City: Atlanta
State: Georgia
Zip: 30326
Phone: 4042669876
Email: specialtyma@pyapc.com
---------------------
Company Information:
Company Name: Pershing, Yoakley & Associates
Company Phone: 4042669876
Company Fax Number:
Company Website:
Type Of Business:
---------------------
Job Details:
Job Title: Medical Assistant
Start Date: August 1, 2016
Job Type: Full-time
Salary Range: $25,000
Referral Source:
---------------------
Job Description:
A specialty practice in Montgomery, AL seeks a Medical Assistant. Prior
experience in a medical practice is preferred. Candidates must have great
interpersonal and customer service skills, and must be self-starters
and multi-taskers – assisting physician with examination and treatment of
patient and maintenance of clinical equipment.
Interested candidates should submit their resume to specialtyma@pyapc.com.
---------------------
Application Process:
---------------------
Hiring Process:
Phone Interview: Yes
Background Check: Yes
Reference Check: Yes
Credit Check: No
Technical Test: No
Personality Test: No
Physical Exam: No
Driving Records: No
Other: No
---------------------
Requested way to receive resumes:
Fax: No
Mail: No
Email: Yes
Apply in person: No
Apply online: No
---------------------
Additional Requests:
The above bolded areas, have to fall into the following areas:
Job Title | Company Name | Description | Contact Name | Contact Email | Zip | Salary | Start Date |
Here is what I have so far (referring to #'s 1-3 above)... which I've placed in ThisOutlookSession of Outlook.
Whatever is not bolded, should not go to the CSV either.
Option Explicit
Private WithEvents Items As Outlook.Items
Private Sub Application_Startup()
Dim olApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Set olApp = Outlook.Application
Set objNS = olApp.GetNamespace("MAPI")
'// The INCOMING JOBS folder must be a folder of the INBOX.
Set Items = objNS.GetDefaultFolder(olFolderInbox).Folders("Incoming Jobs").Items
End Sub
Private Sub Items_ItemAdd(ByVal item As Object)
On Error GoTo ErrorHandler
Dim Msg As Outlook.MailItem
Dim iFile As Integer
If TypeName(item) = "MailItem" Then
Set Msg = item
iFile = FreeFile
Open "C:\Temp\INCOMING_JOBS.CSV" For Append As #iFile
Print #iFile, Replace(Msg.Body, vbCrLf, ",")
Close #iFile
End If
ExitPoint:
Exit Sub
ErrorHandler:
MsgBox Err.Number & " - " & Err.Description
Resume ExitPoint
'// Debug only
Resume
End Sub