Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 06/20/2022 in all areas

  1. I modified the example above to also get the date,from,to in addition to the subject only. For anyone who has some subject lines that look like this below, I found this article: https://dmorgan.info/posts/encoded-word-syntax/ Subject: =?UTF-8?B?VG9wIFdhdGNoYXRob24gcGlja3Mgd2UgdGhpbmsgeW91J2xsIA==?=
    2 points
  2. Here's a small example showing how to loop through the emails. This will print the subject line of the first 100 emails from the inbox. Func Example_Email_Subjects($sServer, $sUser, $sPass) Local $Curl = Curl_Easy_Init() If Not $Curl Then Return Local $emsg = $Curl Curl_Easy_Setopt($Curl, $CURLOPT_USERNAME, $sUser) ; Curl_Easy_Setopt($Curl, $CURLOPT_PASSWORD, $sPass) ; Curl_Easy_Setopt($Curl, $CURLOPT_CAINFO, @ScriptDir & '\curl-ca-bundle.crt') ; Curl_Easy_Setopt($Curl, $CURLOPT_WRITEFUNCTION, Curl_DataWriteCallback()) Curl_Easy_Setopt($Curl, $CURLOPT_WRITEDATA, $emsg) ;Curl_Easy_Setopt($Curl, $CURLOPT_VERBOSE, 1) ; For $i = 1 To 100 ; get full email ;Curl_Easy_Setopt($Curl, $CURLOPT_URL, "imaps://" & $sServer & "/INBOX/;UID=" & $i) ; get subject only ;Curl_Easy_Setopt($Curl, $CURLOPT_URL, "imaps://" & $sServer & "/INBOX/;UID=" & $i & ";SECTION=HEADER.FIELDS%20(SUBJECT)") ; get date,from,to,subject only Curl_Easy_Setopt($Curl, $CURLOPT_URL, "imaps://" & $sServer & "/INBOX/;UID=" & $i & ";SECTION=HEADER.FIELDS%20(DATE%20FROM%20TO%20SUBJECT)") $Code = Curl_Easy_Perform($Curl) ; If $Code = $CURLE_OK Then ConsoleWrite($i & ': ' & BinaryToString(Curl_Data_Get($emsg)) & @CRLF) Curl_Data_Cleanup($emsg); clear data Else ConsoleWrite(Curl_Easy_StrError($Code) & @LF) ExitLoop EndIf Next Curl_Easy_Cleanup($Curl) EndFunc ;==>Example_Email_Subjects
    2 points
  3. Yes you can remove the 1st one. The 2nd one should be enough in your case, it's shorter
    1 point
  4. Nice! I just got a custom request working asking for total count of messages in the inbox which falls inline with what we need to do for the EXAMINE command they talk about. I found this link too with a bunch other custom requests that can be used. All the -X ones. https://gist.github.com/akpoff/53ac391037ae2f2d376214eac4a23634 Func Example_Email_Count($sServer, $sUser, $sPass) Local $Curl = Curl_Easy_Init() If Not $Curl Then Return Local $emsg = $Curl ;set options Curl_Easy_Setopt($Curl, $CURLOPT_USERNAME, $sUser) ; Curl_Easy_Setopt($Curl, $CURLOPT_PASSWORD, $sPass) ; Curl_Easy_Setopt($Curl, $CURLOPT_CAINFO, @ScriptDir & '\curl-ca-bundle.crt') ; Curl_Easy_Setopt($Curl, $CURLOPT_WRITEFUNCTION, Curl_DataWriteCallback()) Curl_Easy_Setopt($Curl, $CURLOPT_WRITEDATA, $emsg) ;Curl_Easy_Setopt($Curl, $CURLOPT_VERBOSE, 1) ; ;Request count of messeges in inbox Curl_Easy_Setopt($Curl, $CURLOPT_CUSTOMREQUEST, "STATUS INBOX (MESSAGES)") ; Curl_Easy_Setopt($Curl, $CURLOPT_URL, "imaps://" & $sServer) ; $Code = Curl_Easy_Perform($Curl) ; If $Code = $CURLE_OK Then ConsoleWrite('email count ' & @CRLF & BinaryToString(Curl_Data_Get($emsg)) & @CRLF & '----****------' & @CRLF) Else ConsoleWrite(Curl_Easy_StrError($Code) & @LF) EndIf Curl_Data_Cleanup($emsg) Curl_Easy_Cleanup($Curl) EndFunc ;==>Example_Email_Count Output: email count: * STATUS INBOX (MESSAGES 61)
    1 point
  5. I was able to get a minimal example going for sending an email via smtp/smtps but it does not save to the sent box. Is that how this is actually implemented? Some kind of combination of using both smtp and imap/pop3? I never thought about what actually makes that happen with the sent messages. I'm mainly working of the examples here https://curl.se/libcurl/c/example.html if anyone else wants to tinker with whatever options exist for the protocols. ; #FUNCTION# ==================================================================================================================== ; Name ..........: Example_Email_Send ; Description ...: Send a Email ; Parameters ....: $sServer - server address. ex: smtp.comcast.net ; $sUser - username/email address ; $sPass - password ; $sTo - recepient address ; $sFrom - sender address ; $sSubject - email subject ; $sBody - email body ; $sProt - protocol. smtp/smtps ; =============================================================================================================================== Func Example_Email_Send($sServer, $sUser, $sPass, $sTo, $sFrom, $sSubject, $sBody, $sProt = 'smtp') ;Build email Local $sHeaders = "To: <" & $sTo & ">" & @CRLF $sHeaders &= "From: <" & $sFrom & ">" & @CRLF ;~ $sHeaders &= "CC: <" & $sCC & ">" & @CRLF ;~ $sHeaders &= "BCC: <" & $sBCC & ">" & @CRLF $sHeaders &= "Subject: " & $sSubject & @CRLF Local $sEmail = $sHeaders & @CRLF & $sBody Local $Curl = Curl_Easy_Init() If Not $Curl Then Return ;Set username and password Curl_Easy_Setopt($Curl, $CURLOPT_USERNAME, $sUser) ; Curl_Easy_Setopt($Curl, $CURLOPT_PASSWORD, $sPass) ; ;set server address and protocol If $sProt = "smtp" Then Curl_Easy_Setopt($Curl, $CURLOPT_URL, "smtp://" & $sServer & ":587") ; Curl_Easy_Setopt($Curl, $CURLOPT_USE_SSL, $CURLUSESSL_ALL) ; ElseIf $sProt = "smtps" Then Curl_Easy_Setopt($Curl, $CURLOPT_URL, "smtps://" & $sServer) ; Else Return ConsoleWrite("invalid protocol" & @CRLF) EndIf ;Set ca bundle for peer verification Curl_Easy_Setopt($Curl, $CURLOPT_CAINFO, @ScriptDir & '\curl-ca-bundle.crt') ; ;build and set recipient list Local $recipients = Curl_Slist_Append(0, $sTo) ; ;$recipients = Curl_Slist_Append($recipients, $sCC); ;$recipients = Curl_Slist_Append($recipients, $sBCC); Curl_Easy_Setopt($Curl, $CURLOPT_MAIL_RCPT, $recipients) ; ;set from address Curl_Easy_Setopt($Curl, $CURLOPT_MAIL_FROM, $sFrom) ; ;Set email data and callback Curl_Data_Put($Curl, $sEmail) Curl_Easy_Setopt($Curl, $CURLOPT_UPLOAD, 1) Curl_Easy_Setopt($Curl, $CURLOPT_READFUNCTION, Curl_DataReadCallback()) Curl_Easy_Setopt($Curl, $CURLOPT_READDATA, $Curl) ;show extra connection info Curl_Easy_Setopt($Curl, $CURLOPT_VERBOSE, 1) ; ;Send email Local $Code = Curl_Easy_Perform($Curl) If $Code = $CURLE_OK Then ConsoleWrite('Email Sent!' & @CRLF) Else ConsoleWrite(Curl_Easy_StrError($Code) & @LF) EndIf ;cleanup Curl_Slist_Free_All($recipients) ; Curl_Easy_Cleanup($Curl) ; EndFunc ;==>Example_Email_Send
    1 point
  6. water

    Outlook Folder View

    Something like this? #include <OutlookEX.au3> Global $sSourceFolder = "Inbox" Global $oOutlook = _OL_Open() Global $oExplorer = $oOutlook.ActiveExplorer Global $oSourceFolder = $oExplorer.CurrentFolder ; Check the current folder If $oSourceFolder.Name = $sSourceFolder Then ; Run your login Script here EndIf ; Access the target folder Global $aTargetFolder = _OL_FolderAccess($oOutlook, "", $olFolderSentMail) $oExplorer.CurrentFolder = $aTargetFolder[1]
    1 point
  7. Hi @Draygoes. Here's a link to a post in the thread with an example: I think this is what you need Hope it helps
    1 point
×
×
  • Create New...