Jump to content

[SOLVED] How do I open an email in outlook with Autoit


Recommended Posts

Hello again everyone, I am trying to make a simple bot/AI to help me at work. I need it to read the subject line of emails, open them if a certain subject line is found, and then copy the contents of the said email and paste it in a different program. 

Can the Autoit outlook UDF help me achieve this? 

Also, I have tried the Outlook UDF and so far I have only figured out how to find all the unread emails (thanks to one of water's example scripts. @water you are a genius just saying).

I am very new to this UDF and would love any help that would guide me into making this bot/AI a reality at work.   

Edited by nooneclose
Link to comment
Share on other sites

  • Moderators

@nooneclose so what have you tried on your own? Showing what code you have tried will always result in your receiving more assistance.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

@JLogan3o13 This is all that I have looked at and tried so far. I would say 95% is just Water's code that I have copied and tested. 

#include <OutlookEX.au3>                                                ;Allows the outlook functions

AutoItSetOption('MouseCoordMode', 0)                                    ;Sets the script to accept coordinates off the program window and not the screen
AutoItSetOption('SendKeyDelay', 10)                                     ;Defines the time it takes to send text to the software/program

;Closes the script if "End" is pressed
$oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

HotKeySet("{END}", "Terminate")
Func Terminate()
    MsgBox($MB_ICONINFORMATION, "DEATH", "Script Stoped!")
    Exit
EndFunc

;*****************************************************************************************************************************************************************
;Script has started
;*****************************************************************************************************************************************************************
Sleep(2000)
MsgBox($MB_ICONINFORMATION, "WO_to_FTE_Bot", "Script Started!")
Sleep(1500)

; *****************************************************************************
; Create test environment
; *****************************************************************************
Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)

; *****************************************************************************
; List all accounts available for the current profile
; *****************************************************************************
Global $aResult = _OL_AccountGet($oOutlook)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_AccountGet Example Script", "Error getting list of accounts for the current profile. @error = " & @error & ", @extended = " & @extended)
_ArrayDisplay($aResult, "OutlookEX UDF: _OL_AccountGet Example Script", "", 0, "|", "|AccountType|Displayname|SMTPAddress|Username|Account object|AutoDiscoverConnectionMode|ExchangeConnectionMode|ExchangeMailboxServerName|ExchangeMailboxServerVersion")

; *****************************************************************************
; Get the first mail in the inbox and display the mail headers
; *****************************************************************************
; Access the inbox
Global $aFolder = _OL_FolderAccess($oOutlook, "", $olFolderInbox)
If @error Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended)

; Find all items in the inbox
Global $aItems = _OL_ItemFind($oOutlook, $aFolder[1], $olMail, "", "", "", "EntryID,Subject", "", 1)
If Not IsArray($aItems) Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended)

; Get the mail headers of the first mail
Global $sMailHeaders = _OL_MailheaderGet($oOutlook, $aItems[1][0])
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_MailheaderGet Example Script", "Error retrieving mail headers of mail with subject '" & $aItems[1][1] & "'. @error = " & @error & ", @extended: " & @extended)
MsgBox(64, "OutlookEX UDF: _OL_MailheaderGet Example Script", "Mail headers of mail with subject '" & $aItems[1][1] & "'." & @CRLF & @CRLF & $sMailHeaders)

;------------------------------------------------------------------------------------------------------------------------------------------------
; Example 4 - Get unread mails from a folder and all subfolders
;------------------------------------------------------------------------------------------------------------------------------------------------
$aItems = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test", $olMail, "[UnRead]=True", "", "", "Subject,Body", "", 1)
If IsArray($aItems) Then
    _ArrayDisplay($aItems, "OutlookEX UDF: _OL_ItemFind Example Script - Unread mails")
Else
    MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Could not find an unread mail. @error = " & @error & ", @extended: " & @extended)
EndIf

_OL_Close($oOutlook)

I still do not know enough about this UDF, and I can not find a function to open and or read an email yet. If they do exist they either do not have clear names or do not do just those operations. Sadly it is looking like there is not a straightforward answer to my question/s or I am easily missing it because I do not understand this UDF yet.  

Again, I want to make something bot/AI that can read a subject line pick certain emails based on the subject line, open the email and copy and paste certain contents of the email into another program. (this would greatly help make a daily task for me at work easier)  

Link to comment
Share on other sites

Replace _OL_MailHeaderGet with _OL_ItemGet to retrieve the subject of a mail.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@water The code below which I changed per your request finds the first email in my inbox and displays the subject line. However, I want to read all emails one at a time and copy and past certain contents. Only the emails that are unread with a certain subject line. (subject line of "blank request")

; Get the mail headers of the first mail
Global $sMailHeaders = _OL_ItemGet($oOutlook, $aItems[1][0])
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_MailheaderGet Example Script", "Error retrieving mail headers of mail with subject '" & $aItems[1][1] & "'. @error = " & @error & ", @extended: " & @extended)
MsgBox(64, "OutlookEX UDF: _OL_MailheaderGet Example Script", "Mail headers with the subject of:'" & $aItems[1][1] & "'." & @CRLF & @CRLF & $sMailHeaders)

if I modify these lines could I get the first of those results?  

$aItems = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test", $olMail, "[UnRead]=True", "", "", "Subject,Body", "", 1)
If IsArray($aItems) Then
    _ArrayDisplay($aItems, "OutlookEX UDF: _OL_ItemFind Example Script - Unread mails")
Else
    MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Could not find an unread mail. @error = " & @error & ", @extended: " & @extended)
EndIf

What I want the code to do:

1. open outlook or a connection to outlook

2. search for any unread email with a certain subject ("blank request") in a certain inbox (inbox is labeled "requests")

3. open that email and copy certain information (not all) and paste that into another program.

4. Leave that open email and search for the next unread email with the subject line of "blank request" 

5. Repeat 3, and 4 until the program is closed. 

 

Am I asking for too much from Autoit? Or am I not being clear? 

Edited by nooneclose
Link to comment
Share on other sites

You have already solved 1) and 2).
2) returns all unread mails. But if you loop through the returned array you can ignore all entries with the "wrong" subject.
3) You already have the mail body in the returned array. Select the needed information from there and paste the array element to the other program
4) Why would you need to leave th processed mail open?
5) Simply to do with a loop

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Thank you for getting back with me @water This is what I have so far.  

; *****************************************************************************
; Create test environment
; *****************************************************************************
Global $oOutlook = _OL_Open()
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF", "Error creating a connection to Outlook. @error = " & @error & ", @extended = " & @extended)


; *****************************************************************************
; List all accounts available for the current profile
; *****************************************************************************
Global $aResult = _OL_AccountGet($oOutlook)
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_AccountGet Example Script", "Error getting list of accounts for the current profile. @error = " & @error & ", @extended = " & @extended)
_ArrayDisplay($aResult, "OutlookEX UDF: _OL_AccountGet Example Script", "", 0, "|", "|AccountType|Displayname|SMTPAddress|Username|Account object|AutoDiscoverConnectionMode|ExchangeConnectionMode|ExchangeMailboxServerName|ExchangeMailboxServerVersion")


; *****************************************************************************
; Get the first mail in the inbox and display the mail headers
; *****************************************************************************
; Access the inbox
Global $aFolder = _OL_FolderAccess($oOutlook, "", $olFolderInbox)
If @error Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended)

; Find all items in the inbox
Global $aItems = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test", $olMail, "", "", "", "EntryID,Subject", "", 1)
If Not IsArray($aItems) Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended)

; Get the mail headers of the first mail
Global $sMailHeaders = _OL_ItemGet($oOutlook, $aItems[1][0])
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_MailheaderGet Example Script", "Error retrieving mail headers of mail with subject '" & $aItems[1][1] & "'. @error = " & @error & ", @extended: " & @extended)
MsgBox(64, "OutlookEX UDF: _OL_MailheaderGet Example Script", "Mail headers with the subject of:'" & $aItems[1][1] & "'." & @CRLF & @CRLF & $sMailHeaders)

; Display the information and contents of the email
_ArrayDisplay($sMailHeaders, "")

_OL_Close($oOutlook)

I was able to figure out how to access the contents of the array with the _ArryDisplay (is this the correct way to do this?)

(PS. My browser glitched so please forgive the lack of format on this reply It will not let me tab or enter)

And yes so far task 1 & 2 are done. A connection is created and I find all the unread emails in the specific folder. I think I did what you said and accessed the mail body in the returned array with _Arraydisplay. (Please tell me if I did it wrong)

As for "4) Why would you need to leave the processed mail open?" I do not want to keep any of the processed emails open. I am sorry if what I said was not clear. I want to mark each processed email as read once the information has been copied and pasted and then close it and then move on to the next unread email. (does this make sense?)

As for the looping until all unread emails with the subject line of "request" have been processed and mark as read. Which loop would you suggest here?        For loop or a while?

Also, I wanted to say thank you very much for the UDF you made. Just to have the possibility of this becoming a real thing is sweet music to my ears. I'm sure I am not the only person who would say your work is more than greatly appreciated.

Edited by nooneclose
Link to comment
Share on other sites

I forgot to ask this in the last post but is there a way to extend the size of the array for the body in the array? (row 9, from 0-9)

when I use _ArrayDisplay and look at the body portion it does not contain the entire body of the email. It is very close though, It only cuts off two sentences worth of info. 

I notice that row28 which holds the HTMlBody has a bigger element size. Where are these values located so that I may change them? 

Like always any help would be greatly appreciated.  

Link to comment
Share on other sites

As _OL_ItemFind returns the EntryID we need to translate it to the corresponding object.

$oItem = $oOL.Session.GetItemFromID($aItems[1][0], Default) ; retrieve the items object
$oItem.Unread = False ; Set the item to read

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

According to the help information in the UDF _OL_Itemfind returns a 1-based 2D array. Means: the 0th element holds the numbr of entries (rows and columns). So the loop should look like:

For $i = 1 to $aItems[0][0]
   ; access the item using: $aItems[$i][0] 
Next

 

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

$oItem = $oOL.Session.GetItemFromID($aItems[1][0], Default) ; retrieve the items object
$oItem.GetInspector
$sBody = $oItem.Body

IIRC you need to call GetInspector to retrieve the full body.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@water This is what I have tried so far and I cannot figure out how to get and open the unread emails with a subject line of 'request'  

;------------------------------------------------------------------------------------------------------------------------------------------------
; Get/List all unread mails from the folder (MT_Inbox)
;------------------------------------------------------------------------------------------------------------------------------------------------
$aItems = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test", $olMail, "[UnRead]=True", "", "", "Subject,Body", "", 1)
If IsArray($aItems) Then
    _ArrayDisplay($aItems, "OutlookEX UDF: _OL_ItemFind - Unread mails")
Else
    MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Could not find an unread mail. @error = " & @error & ", @extended: " & @extended)
EndIf
;_OL_Close($oOutlook)

Local $numberOfUnRead = UBound($aItems, $UBOUND_ROWS) - 1               ; Gets the number of unread emails

Global $emailHeaders = _OL_ItemGet($oOutlook, $aItems[1][0])
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_MailheaderGet", "Error retrieving mail headers of mail with subject '" & $aItems[1][1] & "'. @error = " & @error & ", @extended: " & @extended)
MsgBox(64, "OutlookEX UDF: _OL_MailheaderGet", "MAIL HEADERS WITH THE SUBJECT OF:" & @CRLF & "'" & $aItems[1][1] & "'." & @CRLF & @CRLF & $emailHeaders)

 does 

$aItems[1][1]

know the subject line that I am looking for?

Is it the value that is guiding the search? 

Is this code even trying to find unread emails based on their subject? I am starting to think not. 

Any help would be appreciated. 

 

Also, this code just gives me the error of "OutlookEX UDF: _OL_MailheaderGet", "Error retrieving mail headers of mail with subject '"....

 

Edited by nooneclose
Link to comment
Share on other sites

@water I figured out how to search for the unread emails based on subjects. :) 

Here is my code, I also figured out where and when to input your code to find the body of the email thank you very much. 

Here is what I have so far for this portion of the code. 

;------------------------------------------------------------------------------------------------------------------------------------------------
; Get/List all unread mails from the folder (R_Inbox)
;------------------------------------------------------------------------------------------------------------------------------------------------
$aItems = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test", $olMail, "[UnRead]=True", "Subject", "Request", "EntryID,Subject", "", 1)

If IsArray($aItems) Then
    _ArrayDisplay($aItems, "OutlookEX UDF: _OL_ItemFind - Unread mails")
Else
    MsgBox(48, "OutlookEX UDF: _OL_ItemFind Example Script", "Could not find an unread mail. @error = " & @error & ", @extended: " & @extended)
EndIf
;_OL_Close($oOutlook)

Local $numberOfUnRead = UBound($aItems, $UBOUND_ROWS) - 1               ; Gets the number of unread emails



;*****************************************************************************************************************************************************************
; Get the first mail in the inbox and display the emails contents
;*****************************************************************************************************************************************************************
; Access the inbox
Global $aFolder = _OL_FolderAccess($oOutlook, "", $olFolderInbox)
If @error Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended)

; Find all items in the inbox
Global $aItems = _OL_ItemFind($oOutlook, "*\Outlook-UDF-Test", $olMail, "", "", "", "EntryID,Subject", "", 1)
If Not IsArray($aItems) Then Exit MsgBox(48, "", "@error = " & @error & ", @extended: " & @extended)

; Get the mail headers of the first mail
Global $sMailHeaders = _OL_ItemGet($oOutlook, $aItems[1][0])
If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_MailheaderGet", "Error retrieving mail headers of mail with subject '" & $aItems[1][1] & "'. @error = " & @error & ", @extended: " & @extended)
MsgBox(64, "OutlookEX UDF: _OL_MailheaderGet", "MAIL HEADERS WITH THE SUBJECT OF:" & @CRLF & "'" & $aItems[1][1] & "'." & @CRLF & @CRLF & $sMailHeaders)


$oItem = $oOutlook.Session.GetItemFromID($aItems[1][0], Default) ; retrieve the items object
$oItem.GetInspector
$sBody = $oItem.Body

MsgBox("", "Did this work", $sBody)

All I have to do now is do a loop until all of the unread emails have been processed.

But before I can do that I need to figure out how to use _OL_ItemGet to open each email correct? Or is that not even necessary? 

Link to comment
Share on other sites

If you mean to display a mail item then _OL_ItemGet is not needed.
If you want to access further properties then you could simply retrieve them using _OL_ITemFind (you already use it to retrieve the subject).

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I want to pull data like this: (yes, I want to further access the contents of the email)

$oItem = $oOutlook.Session.GetItemFromID($aItems[1][0], Default) ; retrieve the items object
$oItem.GetInspector

$eBody = $oItem.Body                                                    ; The Body of the email
$eSenderAddress = $oItem.SenderEmailAddress                             ; Customers email address
$eSentOn        = $oItem.SentOn                                         ; When was the email sent?
$eSubject       = $oItem.Subject                                        ; Subject of the email

from the email. 

Also in the body, it is possible to break the information up into pieces on certain words: (see attached image)

I want to take parts of the body and store each of those different bits of information into variables.

like:

$eDescription = ( The email body Description )

$eComments = ( The email body Additional comments )  

Does this make sense?

I would like to take everything after the word "description" and before the word "Additional" and store that string into a variable named "$eDescription"

Once I finish this part I can begin coding the loop process. 

Also thank you for your help so far. I know you have answered a lot of my questions and I must seem annoying at this point.

So thanks for sticking with me during this experience. 

Screenshot (134).png

Link to comment
Share on other sites

Splitting the mailbody into pieces could be a task for StringRegExp (regular expression).

Or use Stringsplit with separator @CRLF or @LF (whichever applies) to split the mailbody into an Array of single lines.
Then loop through the array and check for lines starting with "Description:". Grab the rest of the line using StringMid and all following lines as long as they do not start with "Additional comments:"

Can't post runnable code as I do not have access to a Windows System a the emoment.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

@water I figured out how to break up the body and get the information I wanted...by accident. I'm glad I am able to get the info. It is just that I don't actually understand how my code works. Can you please explain this to me?

;*******************************************************************************
; Gets the Description from the email body
;*******************************************************************************
$eParts1 = StringSplit($eBody, "Description:", $STR_ENTIRESPLIT)
_ArrayDisplay($eParts1, "Pass 1")

$eParts2 = StringSplit($eParts1[2], "Additional" , $STR_ENTIRESPLIT)
_ArrayDisplay($eParts2, "Pass 2")

$eDescription = StringSplit($eParts2[1], "Reported" , $STR_ENTIRESPLIT)
_ArrayDisplay($eDescription, "Description")


;*******************************************************************************
; Gets the Comments from the email body
;*******************************************************************************
$eParts1 = StringSplit($eBody, "comments:", $STR_ENTIRESPLIT)
_ArrayDisplay($eParts1, "Pass 1")

$eParts2 = StringSplit($eParts1[2], "Location" , $STR_ENTIRESPLIT)
_ArrayDisplay($eParts2, "Pass 2")

$eComments = StringSplit($eParts2[1], "Address" , $STR_ENTIRESPLIT)
_ArrayDisplay($eComments, "Comments")

The output of both of those is just what I needed. (you can reference the image I posted last time to see what I started with)

 

So I start with this whole body then I split at one word in pass 1.

Then by Pass 2, a little more is cut out leaving some words behind that I don't want.

Then by Pass 3 everything I don't want is cut out and what I want is left.  

 

Also is there a more efficient way to achieve this? 

Getting closer to being done. Feels good, thanks for your help with this. 😊

Edited by nooneclose
Link to comment
Share on other sites

Glad you got it running :)

Using StringSplit the way you do is one of the many ways to solve your problem. Any other solution might be a bit faster but could be much more complex (like regular expression).

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...