xeroTechnologiesLLC Posted March 1, 2012 Share Posted March 1, 2012 (edited) I've been messing around with the outlook_ex udf (freaking love it, btw) and I was having some trouble getting a file to attach to an email before sending it out. The way I have it now is the user clicks a button and it runs the following: $grabScreenshot = FileOpenDialog("Choose Screenshot", "C:\", "All (*.*)", 1) GUICtrlSetData($inpCscreenshot, $grabScreenshot) Once that's done, an input box has the filename path, directory and all. Once the user clicks 'send report' button it is supposed to email off a static report built from input boxes and such in the program and attach a file IF the user inputs one into the noted input box above. Below is the code I currently have: ; attached file ; gather the entire string, directory and file name, of where the screenshot is $attachedFile = GUICtrlRead($inpCscreenshot) ; gather just the directory witout the file name $i = StringInStr($attachedFile, "\", 0, -1) $attachedFileDirectory = StringLeft($attachedFile, $i) ;~ MsgBox(0, "", $attachedFile & " " & $attachedFileDirectory) $subjectLine = $report & " for " & $dateCapture & " " & $programItem & " " & $versionGet & "Submitted by: " & $submitter Global $aOL_Item = _OL_ItemFind($oOL, $attachedFileDirectory, $olMail, "", "", "", "EntryID") MsgBox(0, "", $aOL_Item) MsgBox(0, "", @error) If $aOL_Item[0][0] = 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemAttachmentAdd Example Script", "Could not find a mail item in folder " & $attachedFileDirectory & ". @error = " & @error) Global $oItem = _OL_ItemAttachmentAdd($oOL, $aOL_Item, Default, $attachedFile) If @error <> 0 Then Exit MsgBox(16, "OutlookEX UDF: _OL_ItemAttachmentAdd Example Script", "Error adding attachment to mail item in folder " & $attachedFileDirectory & ". @error = " & @error & ", @extended = " & @extended) $bodyOfEmail = "" $bodyOfEmail = "This email was sent because the program has detected an interruption in communication to the ticketting site. Please review the report. Note: do not reply back to this address. Thank you." & @CRLF & _ $submitter & " from the " & $team & " team" & " submitted the following:" & @CRLF & @CRLF & _ @TAB & @TAB & " .:. Bug Report:" & @CRLF & _ "Program: " & $programItem & @CRLF & _ "Date of the error: " & @TAB & $errordate & @CRLF & _ "Type of error: " & @TAB & $errortype & @CRLF & @CRLF & _ "Details on the error noted above: " & @CRLF & _ $errorDetails & @CRLF & @CRLF & _ "Description of what was done at the time of the error:" & @CRLF & _ $moreErrorDetails & @CRLF & @CRLF & _ " .:. Extra Comments:" & @CRLF & _ $extraComments & @CRLF _OL_Wrapper_SendMail($oOL, "user, some", "", "", $subjectLine, $bodyOfEmail) Over the last few hours I've been reading through the help files provided with the outlook UDF, but I'm not 100% sure where I'm going wrong? The output from the message boxes: MsgBox(0, "", $aOL_Item) MsgBox(0, "", @error) ...are nothing and 0; if that helps any what so ever. Essentially I want the program to send an email to the break-fix team (which is us..heh) with the screenshot file that was selected in the input box prior in the program. If there is an easier way to do it, using the outlook udf or other route - i am absolutely open to suggestions. Please let me know if there is anything further needed to help with this. -Nick Edited April 7, 2012 by xeroTechnologiesLLC Link to comment Share on other sites More sharing options...
xeroTechnologiesLLC Posted March 1, 2012 Author Share Posted March 1, 2012 Resolved. I was over complicating it. _OL_Wrapper_SendMail($oOL, "lastname, firstname", "", "", $subjectLine, $bodyOfEmail, $attachedFile) The _OL_Wrapp_Sendmail has a 'property' for attaching a file. /eyes the Monster Zero can/ you have failed me for the last time.... Link to comment Share on other sites More sharing options...
water Posted March 1, 2012 Share Posted March 1, 2012 (edited) The problem is lineGlobal $aOL_Item = _OL_ItemFind($oOL, $attachedFileDirectory, $olMail, "", "", "", "EntryID")You use function _OL_ItemFind the wrong way. To create a new mail and add an attachment you would either need _OL_Wrapper_SendMail (as you have done) or use function _OL_ItemCreate to create an email and _OL_ItemAttachmentAdd to add the attachment. Over the last few hours ...If you need more than 30 minutes without finding a solution, post on the OutlookEX support thread and if I'm around I'm trying to help you. Edited March 1, 2012 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 Link to comment Share on other sites More sharing options...
xeroTechnologiesLLC Posted March 2, 2012 Author Share Posted March 2, 2012 water, Thank you very much for the reply. The info is good to know for the future because I know I will be using this again. It's absolutely invaluable to the work we are doing here and I can't possibly thank the creators and supporters of it enough! I will keep your note in mind for time taken and where to post for future help. Due to my schedule I often end up developing solo for the weekend (IE no other minds to pick for advice) so I'm trying to get in the habit of learning it myself or finding the answer myself, etc. But I will keep it in mind for the future and you know I'll have more questions! LOL Thanks again! Link to comment Share on other sites More sharing options...
water Posted March 2, 2012 Share Posted March 2, 2012 Glad to be of service And keep the questions rolling in! 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 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