Suki Posted March 4, 2017 Share Posted March 4, 2017 Hi I am trying to add an attachment and send via outlook exchange. I am not going to use smtp, since the client is on exchange server. below is my code Local $olMailItem = 0 Local $olFormatRichText = 3 Local $olImportanceLow = 0 Local $olImportanceNormal = 1 Local $olImportanceHigh = 2 Local $olByValue = 1 Local $olFormatHTML = 2 Local $olFormatPlain = 1 local $xyz=678 $oOApp = ObjCreate("Outlook.Application") $oOMail = $oOApp.CreateItem ($olMailItem) $oOMail.Save With $oOMail ;.To = ("sukirti.x.sen@accenture.com") .Subject = "test mail" .BodyFormat = $olFormatRichText ;.Importance = $olImportanceNormal .Body = "test1234"& $xyz .attachments.add("C:\Users\sukirti.x.sen\Desktop\New folder (2)\PIndex.xls") .display ;.Send EndWith $oOApp=0 Mail is getting sent but attachment is not working , I am on outlook 2016. I tried many variants, .attachements.add , attachmentsadd etc but the attachment is not getting added to the mail. Everything else works though and I have run through hours of past discussions on this on the forums but the attachment is still not getting added Link to comment Share on other sites More sharing options...
water Posted March 4, 2017 Share Posted March 4, 2017 (edited) Why don't you use my OutlookEX UDF? Either use wrapper function _OL_Wrapper_SendMail or single function calls for _OL_ItemCreate, _OL_ItemAttachmentAdd and _OL_ItemSend. Edited March 4, 2017 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Suki Posted March 5, 2017 Author Share Posted March 5, 2017 your udf is great but it is too complex and I have time deadlines...any clues why the .attachments.add is not working? I have seen posts in the forum where it is working for some people Link to comment Share on other sites More sharing options...
water Posted March 5, 2017 Share Posted March 5, 2017 Complex? #include <OutlookEX.au3> Global $oOL = _OL_Open() Global $oItem = _OL_Wrapper_SendMail($oOL[, "sukirti.x.sen@accenture.com", "", "", "Test Mail", "test1234", "C:\Users\sukirti.x.sen\Desktop\New folder (2)\PIndex.xls", $olFormatRichText, $olImportanceNormal) If @error then Exit MsgBox(0, "Error", "@error = " & @error & ", @extended = " & @extended) $oItem.Display() My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Suki Posted March 5, 2017 Author Share Posted March 5, 2017 unh the outlookex.au3 installation gives error when i try to build. Anyway, i do not want to use something i do not understand. What is wrong with my code and why is attachments.add not working? It looks simple, and the rest of the mail functionality is working Link to comment Share on other sites More sharing options...
Suki Posted March 5, 2017 Author Share Posted March 5, 2017 hi- Please give up working on this, my code was right and of course your code was much better and much more correct than mine. Issue - the excel files ends with .xlsx and not .xls , lesson learnt for me after spending 5 hours on this simple piece of code, many apologies for wasting your time Link to comment Share on other sites More sharing options...
water Posted March 5, 2017 Share Posted March 5, 2017 Glad the problem could be solved _OL_Wrapper_SendMail would have set @error to 5002. This tells us that the file to attach could not be found. That's not too complex, is it? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Suki Posted March 5, 2017 Author Share Posted March 5, 2017 hmm i did not get to look into that.. i am getting errors installing your outlook UDF. I have tried uninstall / install a couple of times but it gives errors, might be something to do with my system or OS. First couple of time i got an error - could not copy from outlookexconstants. I uninstalled deleted the edf and the zip extract and installed it again, but this time it gives me some variable being used without being declared error. I am 100% sure that this is something to do with the installation and I am going to delete all files and reinstall your UDF once i knock of whatever I am doing.there are many functions which you have written and which are definitely great to look through , both from a learning and usage perspective. Many thanks once agaim Link to comment Share on other sites More sharing options...
water Posted March 5, 2017 Share Posted March 5, 2017 (edited) What do you mean by installing? The UDF contains a lot of files (help file for each function, example for each function etc.) but you only need two files OutlookEX.au3 and OutlookEXConstants.au3,. Save them in the directory where your script resides or the User Defined Include Directory. That's it. This is documented in ReadMe.txt which is part of the downloaded file. Edited March 5, 2017 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 - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
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