Outlook Parse

Firstartemis

New Member
Joined
Jun 17, 2015
Messages
10
Thank you to all who have helped me before. Without you guys, I would still be lost in the many projects my bosses think I can handle in my off time...

I've been given a task to automate a survey that will be sent via email (survey sample response below). Due to inbox limitations and bandwidth I'm thinking it would be better to receive the form via plain text (business practices forbid html), although we will be sending the form out via word form. I'm looking for a macro that parses outlook 2007 and populates an access database. Additionally, if it could automatically delete the email after parsing, it would be extremely helpful.

Notes: Each 2 letter abbreviation corresponds to a separate part of the form with MF## having upto 100 options

Thank you for your assistance.

email macro
Code:
Private Sub CommandButton1_Click()
Dim outlookapp As Object
Dim item As Object
Dim subject As String
Dim strEmail As String
Dim strBody As String

Dim Doc As Document

Set Doc = ThisDocument

strEmail = Doc.FormFields("txtCRep").Result
strBody = "Do not edit anything below this line" & Chr(13)

Dim fld As FormField
For Each fld In ActiveDocument.FormFields
If fld.Result <> "0" Then
strBody = strBody + (fld.Name & Chr(124) & fld.Result & Chr(13))
End If
Next




        
    Set outlookapp = CreateObject("outlook.application")

    
    subject = "RNA"
    Set item = outlookapp.CreateItem(0)

    With item
        .To = strEmail
        .subject = subject
        .Body = strBody
        .Display
        
    End With

    End Sub

Sample Response:
Code:
Do not edit anything below this line
txtCRep|
MI3|1
MI7|1
Rank|E1
Branch|USN
Rate|Im1
Lname|Smart
Command|USS Neversail
FName|Fellar
Department|
Memail|first.last@myemail.mil
Division|
CEmail|
WCenter|
WPhone|(123) 456-7890
PRD|
EAOS|
CPhone|(124) 567-7890
MF9|1
MF11|1
MF50|1
MF27|1
MF31|1
MN2|1
MN6|1
In2b|
IN3|1
IN5|1
OIQ|My response is here
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,214,950
Messages
6,122,438
Members
449,083
Latest member
Ava19

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