Rapidnxit

[solved] send multiple files by email from a file list

2 posts in this topic

#1 ·  Posted (edited)

Hi! I want to send by mail some files with a certain extension (.xml in my case). These files are located in the script folder. First, I thought to use _FileListToArrayRec function to have a list of these files. But than I don't know how to send them all at once. I know that I can attach multiple files in this way: path1;path2;path3; etc.  and so I have tried to make a string of this type with the path of the files (with a for loop) but It doesn't attach any file (only instructions.txt). How could I do? ( what I did is just an idea, if there's something better that would be great) Thanks!

$aArrayXml = _FileListToArrayRec(@ScriptDir, "*.xml", $FLTAR_FILES)
_ArrayDisplay($aArrayXml, "LIST XML")
$LenghtArrayXml = UBound($aArrayXml)

If ($LenghtArrayXml > 2) Then
    For $i = 2 To $LenghtArrayXml - 1
        $temp = "&@ScriptDir&""\"&$aArrayXml[$i]&";"&""""
        $XmlListFile = $XmlListFile & $temp
    Next
EndIf

$XmlListFile = StringTrimLeft($XmlListFile, 1)

if($LenghtArrayXml = 2)Then
    $rc =_INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @ScriptDir&"\"&$aArrayXml[1]&";"&@ScriptDir&"\instructions.txt", $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl)
Else
    $rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, @ScriptDir&"\"&$aArrayXml[1]&$XmlListFile&@ScriptDir&"\instructions.txt", $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl)
EndIf

 

Edited by Rapidnxit
solved

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Omg it was so easy. I could make a string with the files path with _ArrayToString function

$sAtt = _ArrayToString($aArrayXml, ";", 1)
Edited by Rapidnxit
update

Share this post


Link to post
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

  • Similar Content

    • tremolux66
      Exclusive file locking
      By tremolux66
      I've run into the problem where multiple script processes writing to a log file at the same time can interfere with one another. That is, file writes using FileWriteLine are not atomic, so a line of text from one process can have fragments of text from other processes mixed in with it. Exclusive file-locking should take care of the problem.
      Looking through the standard UDFs, I see that _WinAPI_LockFile is available, but according to the MSDN documentation it doesn't block - it returns immediately if the lock can't be obtained - and there doesn't seem to be a UDF for the LockFileEx function. I considered writing my own UDF for LockFileEx, but some aspects (e.g., creating the OVERLAPPED structure and its members) look too complex for the amount of time I have available. I think approximating LockFileEx using LockFile could solve my problem, but I'd like to keep it simple while still working reliably. I'm not confident that (e.g.) a simple retry loop to simulate blocking will be adequate.
      Any suggestions for a simple way to achieve exclusive file-locking with blocking?
    • Ahile07
      Old fashion way search array
      By Ahile07
      Hello guys. Again a dummy question for smart people.
      I'm wondering if any of you can help me with an issue. I've got a list of names that i would like to store into an array variable. Example $names = [name1][name2][name3]
      Then i've got an inputbox that asks for your name. I don't know how i can be able to see if the inputbox value is different then the names. I've done already separate if statements if the values are = with the names. But i want to check for error in case the value of the inputbox is different then my list of names.
      Hope it makes sense.
      Thank you
    • Dent
      [SOLVED] Help with Array's (creating 1 Array from 2 Arrays)
      By Dent
      I just can't get my head around what I'm trying to do.
      Ok so I read all the links in a webpage into a 1D array, I then make the array unique as there are some duplicates.
      I then find all the entries I want from the array and put the number of the row for those entries into another 1D array.
      So I now have two arrays; one has unique links, the other has the numbers of the rows for the links I actually want.
      Using the second array I would like to amend the first array, or create a third, with just the links I actually want.
      Confused? Welcome to my world.
      I'll put the relevant section of code below to show where I am up to.
      I've left the _ArrayDisplay in the above code which I am using to check the code does what I wanted. So the above code works fine, I'm just stumped on how to extract the links from $aLinks that I want.
      $oLinks = _IELinkGetCollection($oIE) Local $aLinks[1] = ["Link"] For $oLink in $oLinks _ArrayAdd($aLinks, $oLink.href) Next ;_ArrayDisplay($aLinks) $aLinks = _ArrayUnique($aLinks) ;_ArrayDisplay($aLinks) $aLinksToClick = _ArrayFindAll($aLinks, "azref", 0, 0, 0, 3) ;_ArrayDisplay($aLinksToClick) Local $aSortedLinks[1] = ["Sorted Links"] For $i = 0 To UBound($aLinksToClick) - 1 $Blah = _ArrayExtract($aLinks, $aLinksToClick[$i], $aLinksToClick[$i]) _ArrayAdd($aSortedLinks, $Blah) Next  
    • jloyzaga
      simple multi list box
      By jloyzaga
      I'd just like to find an example of a multi select list box that outputs the selections to a file. Finding lots of complex examples in examples folder and cannot find and simple ones. like simple single select list box. 
      I'm trying to put together a selection criteria. where listbox 1 has a list of environment names - when selected it will open up another control (overlay is good to cover first GUI) it then lists Applications. When selected I will use the selection to list some items from excel as a multi select list box. So are there simple examples of these that i can look at and use to create a gui that I can understand?
       
      Joe
    • ruslanas402
      Open webpages by checking boxes
      By ruslanas402
      Hello everyone, don't even know how to ask.  My code is:
      #include <String.au3> #include <IE.au3> #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> $Form1 = GUICreate("Form1", 700, 500, 192, 124) $Button1 = GUICtrlCreateButton("View", 576, 24, 89, 41) Global $oIE = _IECreate("https://www.youtube.com/playlist?list=PL4Jcq5zn02jKpjX0nqI1_fS7mEEb5tw6z", 1, 1, 0) Sleep(1000) Global $sHTML = _IEDocReadHTML($oIE) $FirstChunks = _StringBetween($sHTML, 'pl-video-title-link yt-uix-tile-link yt-uix-sessionlink', '<div class="pl-video-owner') $x = 16 For $a In $FirstChunks $actualdata = _StringBetween($a, '">', '</a>') ;$actualdata2 = _StringBetween($a, 'href="', '&amp;') $Checkbox1 = GUICtrlCreateCheckbox($actualdata[0], 24, $x, 500, 17) $x = $x + 20 Next GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Somehow I need to open webpages where checkbox is checked by presing button view, I think I need somehow asign $actualdata with $actualdata2. Any ideas would be very appreciated