Prev: msgbox on top
Next: Trim?
From: James Robertson on 4 Mar 2010 15:12 Here is the script that I am using and it works well except that it does not ignore the case of the attached files. Can any one give me the peice that I need to have it ignore the case of the attached file? <SCRIPT LANGUAGE="VBScript"> Sub ExStoreEvents_OnSave(pEventInfo, bstrURLItem, lFlags) Set msgobj = CreateObject("CDO.Message") msgobj.DataSource.Open bstrURLItem For Each objAttachment In msgobj.Attachments If InStr(objAttachment.filename,"Register Document") > 0 Then objAttachment.SaveToFile "\\Server\c$\Inetpub\Intranet\Documents\" & objAttachment.filename End If Next Set msgobj = Nothing End Sub </SCRIPT>
From: John J. Jobst on 4 Mar 2010 16:02 Use the lowercase function on the filename and compare it to a lowercase string. "James Robertson" <JamesRobertson(a)discussions.microsoft.com> wrote in message news:5BF97151-3953-44B5-92C2-0FBEAFB16062(a)microsoft.com... > Here is the script that I am using and it works well except that it does > not > ignore the case of the attached files. Can any one give me the peice that > I > need to have it ignore the case of the attached file? > > <SCRIPT LANGUAGE="VBScript"> > Sub ExStoreEvents_OnSave(pEventInfo, bstrURLItem, lFlags) > Set msgobj = CreateObject("CDO.Message") > msgobj.DataSource.Open bstrURLItem > For Each objAttachment In msgobj.Attachments > If InStr(objAttachment.filename,"Register Document") > 0 Then > objAttachment.SaveToFile > "\\Server\c$\Inetpub\Intranet\Documents\" & objAttachment.filename > End If > Next > Set msgobj = Nothing > End Sub > </SCRIPT>
From: Tom Lavedas on 4 Mar 2010 16:51 On Mar 4, 4:02 pm, "John J. Jobst" <john.j.jo...(a)usace.army.mil> wrote: > Use the lowercase function on the filename and compare it to a lowercase > string. > > "James Robertson" <JamesRobert...(a)discussions.microsoft.com> wrote in > messagenews:5BF97151-3953-44B5-92C2-0FBEAFB16062(a)microsoft.com... > > > Here is the script that I am using and it works well except that it does > > not > > ignore the case of the attached files. Can any one give me the peice that > > I > > need to have it ignore the case of the attached file? > {snip} Instr also has an argument that can make it ignore case. From WSH documentation (good source for VBS info): Returns the position of the first occurrence of one string within another. InStr([start, ]string1, string2[, compare]) Arguments start Optional. Numeric expression that sets the starting position for each search. If omitted, search begins at the first character position. If start contains Null, an error occurs. The start argument is required if compare is specified. string1 Required. String expression being searched. string2 Required. String expression searched for. compare Optional. Numeric value indicating the kind of comparison to use when evaluating substrings. See Settings section for values. If omitted, a binary comparison is performed. The compare argument can have the following values: Constant Value Description vbBinaryCompare 0 Perform a binary comparison. vbTextCompare 1 Perform a textual comparison. So this should work as well ... If InStr(1, objAttachment.filename,"Register Document", 1) > 0 Then _____________________ Tom Lavedas
From: James Robertson on 4 Mar 2010 17:14 John thanks for the post, but I found in another area of the WWW that Tom Lavedas had also posted the following from http://www.keyongtech.com/5514325-ignoring-case in which I modified the line If InStr(objAttachment.filename,"Court Register") > 0 Then With If InStr(1, objAttachment.filename,"Court Register", 1) > 0 Then and that solved the problem. John and Tom thank you for providing the expertise in solving this old issue. "John J. Jobst" wrote: > Use the lowercase function on the filename and compare it to a lowercase > string. > > "James Robertson" <JamesRobertson(a)discussions.microsoft.com> wrote in > message news:5BF97151-3953-44B5-92C2-0FBEAFB16062(a)microsoft.com... > > Here is the script that I am using and it works well except that it does > > not > > ignore the case of the attached files. Can any one give me the peice that > > I > > need to have it ignore the case of the attached file? > > > > <SCRIPT LANGUAGE="VBScript"> > > Sub ExStoreEvents_OnSave(pEventInfo, bstrURLItem, lFlags) > > Set msgobj = CreateObject("CDO.Message") > > msgobj.DataSource.Open bstrURLItem > > For Each objAttachment In msgobj.Attachments > > If InStr(objAttachment.filename,"Register Document") > 0 Then > > objAttachment.SaveToFile > > "\\Server\c$\Inetpub\Intranet\Documents\" & objAttachment.filename > > End If > > Next > > Set msgobj = Nothing > > End Sub > > </SCRIPT> > > > . >
From: "Dave "Crash" Dummy" on 4 Mar 2010 17:46
James Robertson wrote: > John thanks for the post, but I found in another area of the WWW that > Tom Lavedas had also posted the following from > http://www.keyongtech.com/5514325-ignoring-case in which I modified > the line > > If InStr(objAttachment.filename,"Court Register") > 0 Then > > With > > If InStr(1, objAttachment.filename,"Court Register", 1) > 0 Then > > and that solved the problem. John and Tom thank you for providing > the expertise in solving this old issue. Tom's way is probably bets, but there is usually more than one way to skin a cat. This should also work: If InStr(lcase(objAttachment.filename),"court register") > 0 Then -- Crash "Something there is that doesn't love a wall, that wants it down." ~ Robert Frost ~ |