IQ9003 Posted July 20, 2010 Posted July 20, 2010 Hi, Here is a small piece of code which I use. (Tested with outlook 2003, with the proper permissions to read the other mailbox!) This code saves an attachement in a mail from a different mailbox (it only saves attachements with the name brief.doc) expandcollapse popup#Include <Array.au3> #Include <File.au3> local $teller ;$teller=Opslaanbijlagen("Caixa de correios - Cadastro Credito - VC\Inbox", "c:\temp") $teller=Opslaanbijlagen("Postvak - Name\Postvak IN\Test", "c:\temp\") ;=============================================================================== ; ; Function Name: Opslaanbijlagen ; Description: Opslaan van alle bijlagen die aan de criteria voldoen ; Syntax.........: Opslaanbijlagen("Postvak - Mijnaam\test\subtest","C:\temp" ) ; Requirement(s): AutoIt3 with COM support (post 3.1.1) ; Return Value(s): Not used in this example ; ; Author(s): Iq9003 ; Created: 08072009 ; Modified: ; ;=============================================================================== Func Opslaanbijlagen($Postbus_user, $tempdir) $oOApp = ObjCreate("Outlook.Application") $myNamespace =$oOApp.GetNamespace("MAPI") ; Original folder $myarrayold=StringSplit ( $Postbus_user, "\") $myOldFolder = $myNamespace.Folders($myarrayold[1]) For $i=2 to $myarrayold[0] $myOldFolder=$myOldFolder.Folders($myarrayold[$i]) next For $a=$myOldFolder.Items.count to 1 Step -1 $teller=$teller+1 $iAttachCnt = $myOldFolder.Items($a).Attachments.Count If $iAttachCnt > 0 Then For $iAttachNum = 1 to $iAttachCnt $oTemp = $myOldFolder.Items($a).Attachments.Item($iAttachNum) $sFileName = $oTemp.FileName $oTemp = $myOldFolder.Items($a).Attachments.Item($iAttachNum) if stringinstr($sFileName,".doc") > 0 and stringinstr($sFileName,"Brief") > 0 then $oTemp.SaveAsFile ($tempdir & $teller & $sFileName ) endif Next EndIf next return $teller endfunc
SeF Posted August 23, 2010 Posted August 23, 2010 (edited) Hi, Here is a small piece of code which I use. (Tested with outlook 2003, with the proper permissions to read the other mailbox!) This code saves an attachement in a mail from a different mailbox (it only saves attachements with the name brief.doc) expandcollapse popup#Include <Array.au3> #Include <File.au3> local $teller ;$teller=Opslaanbijlagen("Caixa de correios - Cadastro Credito - VC\Inbox", "c:\temp") $teller=Opslaanbijlagen("Postvak - Name\Postvak IN\Test", "c:\temp\") ;=============================================================================== ; ; Function Name: Opslaanbijlagen ; Description: Opslaan van alle bijlagen die aan de criteria voldoen ; Syntax.........: Opslaanbijlagen("Postvak - Mijnaam\test\subtest","C:\temp" ) ; Requirement(s): AutoIt3 with COM support (post 3.1.1) ; Return Value(s): Not used in this example ; ; Author(s): Iq9003 ; Created: 08072009 ; Modified: ; ;=============================================================================== Func Opslaanbijlagen($Postbus_user, $tempdir) $oOApp = ObjCreate("Outlook.Application") $myNamespace =$oOApp.GetNamespace("MAPI") ; Original folder $myarrayold=StringSplit ( $Postbus_user, "\") $myOldFolder = $myNamespace.Folders($myarrayold[1]) For $i=2 to $myarrayold[0] $myOldFolder=$myOldFolder.Folders($myarrayold[$i]) next For $a=$myOldFolder.Items.count to 1 Step -1 $teller=$teller+1 $iAttachCnt = $myOldFolder.Items($a).Attachments.Count If $iAttachCnt > 0 Then For $iAttachNum = 1 to $iAttachCnt $oTemp = $myOldFolder.Items($a).Attachments.Item($iAttachNum) $sFileName = $oTemp.FileName $oTemp = $myOldFolder.Items($a).Attachments.Item($iAttachNum) if stringinstr($sFileName,".doc") > 0 and stringinstr($sFileName,"Brief") > 0 then $oTemp.SaveAsFile ($tempdir & $teller & $sFileName ) endif Next EndIf next return $teller endfunc It worked just fine! (Just changed a couple of things, like the .doc and "Brief", to make compatible to mine) Thank you very much! Edited August 23, 2010 by SeF
ICANSEEYOU7687 Posted August 24, 2010 Posted August 24, 2010 Are there any plans too add an "Add member to dist list"
BartvanBeek Posted September 13, 2010 Posted September 13, 2010 It's impossible to run ObjCreate("Outlook.Application") under Windows 7 (64-bit) Can anyone help me please to solve this problem? Thanks! Func _OutlookOpen() Local $oOutlook = ObjCreate("Outlook.Application") If @error Or Not IsObj($oOutlook) Then Return SetError(1, 0, 0) EndIf Return $oOutlook EndFunc
Rigest Posted September 14, 2010 Posted September 14, 2010 (edited) I really found this UDF usefull. I've encountered a problems and I hope someone can help me with that. The problem is that I can't find any option to add a sender when sending an e-mail (as in: this e-mail is from). I've several accounts and I don't want the e-mail to be sent from the default account, is there anyway to change this?Thanks in advanche! Edited September 14, 2010 by Rigest
Rigest Posted September 17, 2010 Posted September 17, 2010 I really found this UDF usefull. I've encountered a problems and I hope someone can help me with that. The problem is that I can't find any option to add a sender when sending an e-mail (as in: this e-mail is from). I've several accounts and I don't want the e-mail to be sent from the default account, is there anyway to change this?Thanks in advanche!Does anyone know if this is possible? Because this UDF is perfect for what I need, but I really need to change the sender from the default one. If this isn't possible I have to work with the mouse and send commands, and that's just so much slower (and looks worse).
water Posted September 17, 2010 Posted September 17, 2010 (edited) It's possible - but not with the Outlook UDF. You could use a customized version of the _OutlookSendMail function (Ex stands for extended) in combination with the Oudlook UDF: Func _OutlookSendMailEx($oOutlook, $sFrom = "", $sTo = "", $sCc = "", $sBcc = "", $sSubject = "", $sBody = "", $sAttachments = "", $iBodyFormat = $olFormatPlain, $iImportance = $olImportanceNormal, $sWarningClick = "") Local $iRc = 0, $asAttachments If $sTo = "" And $sCc = "" And $sBcc = "" Then Return SetError(1, 0, 0) EndIf If $sWarningClick <> "" And FileExists($sWarningClick) = 0 Then Return SetError(2, 0, 0) Else Run($sWarningClick) EndIf Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") Local $oMessage = $oOutlook.CreateItem($olMailItem) $oMessage.To = $sTo $oMessage.Cc = $sCc $oMessage.Bcc = $sBcc $oMessage.From = $sFrom ; <== This line and parameter $sFrom is the only difference to the UDF function $oMessage.Subject = $sSubject $oMessage.Body = $sBody $oMessage.BodyFormat = $iBodyFormat $oMessage.Importance = $iImportance If $sAttachments <> "" Then $asAttachments = StringSplit($sAttachments, ";") For $iNumOfAttachments = 1 To $asAttachments[0] $oMessage.Attachments.Add($asAttachments[$iNumOfAttachments]) Next EndIf $oMessage.Send $iRc = @error If $iRc = 0 Then Return 1 Else Return SetError(9, 0, 0) EndIf EndFunc ;==>_OutlookSendMailEx Edited September 17, 2010 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
Rigest Posted September 17, 2010 Posted September 17, 2010 Thanks a lot Water! Really appreciat it! Gonna try it out this weekend =)
nico18n Posted September 20, 2010 Posted September 20, 2010 Hello, I have a problem to extract emails from Outlook local folders. folder is a local store. How can I do? I tried to use various methods already mentioned, but I can not. It's good for your inbox. Hello and thank you.
water Posted September 21, 2010 Posted September 21, 2010 (edited) I had a quick look at the code. It seems to be possible to specify a different folder as second parameter to _OutlookGetMail. Is has to have a format of \\FolderID\\StoreID. Unfortunately I don't know how to get this information for a local store. Maybe Wooltown can shed some light on this? Edited September 21, 2010 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
Rigest Posted September 21, 2010 Posted September 21, 2010 It's possible - but not with the Outlook UDF. You could use a customized version of the _OutlookSendMail function (Ex stands for extended) in combination with the Oudlook UDF: Func _OutlookSendMailEx($oOutlook, $sFrom = "", $sTo = "", $sCc = "", $sBcc = "", $sSubject = "", $sBody = "", $sAttachments = "", $iBodyFormat = $olFormatPlain, $iImportance = $olImportanceNormal, $sWarningClick = "") Local $iRc = 0, $asAttachments If $sTo = "" And $sCc = "" And $sBcc = "" Then Return SetError(1, 0, 0) EndIf If $sWarningClick <> "" And FileExists($sWarningClick) = 0 Then Return SetError(2, 0, 0) Else Run($sWarningClick) EndIf Local $oOuError = ObjEvent("AutoIt.Error", "_OutlookError") Local $oMessage = $oOutlook.CreateItem($olMailItem) $oMessage.To = $sTo $oMessage.Cc = $sCc $oMessage.Bcc = $sBcc $oMessage.From = $sFrom ; <== This line and parameter $sFrom is the only difference to the UDF function $oMessage.Subject = $sSubject $oMessage.Body = $sBody $oMessage.BodyFormat = $iBodyFormat $oMessage.Importance = $iImportance If $sAttachments <> "" Then $asAttachments = StringSplit($sAttachments, ";") For $iNumOfAttachments = 1 To $asAttachments[0] $oMessage.Attachments.Add($asAttachments[$iNumOfAttachments]) Next EndIf $oMessage.Send $iRc = @error If $iRc = 0 Then Return 1 Else Return SetError(9, 0, 0) EndIf EndFunc ;==>_OutlookSendMailEx You are incorrect, but you've helped me on the right way. It should be: $oMessage.Sentonbehalfofname = $sFrom. Tnx anyway
nico18n Posted September 22, 2010 Posted September 22, 2010 (edited) I had a quick look at the code. It seems to be possible to specify a different folder as second parameter to _OutlookGetMail.Is has to have a format of \\FolderID\\StoreID....hello,I've tried does not work.Instead it seems that the function works well IQ9003 (Opslaanbijlagen) that does not use Outlook-UDF.but i want to use with outlook-UDF. Can you help? Edited September 24, 2010 by nico18n
PeterAtkin Posted October 2, 2010 Posted October 2, 2010 this looks really good, this may be a bit off topic but is it possible to get the e-mail and user settings from outlook? [topic='115020'] AD Domain Logon Script[/topic]
srikanthsurabhi Posted October 3, 2010 Posted October 3, 2010 I found this UDF very useful.. Thank you very much folks.. Regards Srikanth
QAuser Posted October 26, 2010 Posted October 26, 2010 Hi I find the information here really interesting. But my problem is to insert in an rtf mail an inline picture. it means not as an attachment but the picture should appears in the mail. The second point is that i want to send some mail with some rtf. data as attachemnt but this rtf data should be attached as text not as normal attachemnt. Can anybody have an idea how i can do it . Thank you
Wooltown Posted October 27, 2010 Author Posted October 27, 2010 Hello ! It was a long time since I updated this UDF, unfortunatelly I have very little time now. It would have been great if there were an area somewhere in the forum (or elsewhere) where users can contribute to a UDF written. Contribution can consist of error correction, enhancements, nice examples etc. If the AutoIT team could do that it would have been great for the community.
water Posted October 27, 2010 Posted October 27, 2010 ... It would have been great if there were an area somewhere in the forum (or elsewhere) where users can contribute to a UDF written. Contribution can consist of error correction, enhancements, nice examples etc. ...D'accord! That's what I have done with the Active Directory UDF. After contacting the owner of the UDF I started to enhance the UDF with help files, examples, extended error checking and some new functions.It would be great if we could do that for other UDFs as well! My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
Wooltown Posted October 27, 2010 Author Posted October 27, 2010 The best thing would have been some kind of area where we can store it outside the forum
water Posted October 30, 2010 Posted October 30, 2010 ... where users can contribute to a UDF written. Contribution can consist of error correction, enhancements, nice examples etc. ...If you like I can have a look at your UDF and create a list of things I can start working on. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.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 (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
Wooltown Posted November 1, 2010 Author Posted November 1, 2010 Please do, it can be found in the beginning of this post
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now