FW: How to save the attachment in Microsoft outlook using perl-code
* # Count a attachments* *my* $AttachmentNb = $message-Attachments()-Count(); *# Create attachments filename list * *my* $AttachmentsList; *if*($AttachmentNb 0){ *for* (*my* $i=1;$i = $AttachmentNb;$i++){ *# Add attachment filename to the list * $AttachmentsList .= $message-Attachments()-Item($i)-FileName().\r\n ; *# Save attachement as its filename in path of your choice [ c:\ in this example ]* $message-Attachments()-Item($i)-SaveAsFile( 'c:\\'.$message-Attachments()-Item($i*)-*FileName()); } } Benoit Quenneville FW: How to save the attachment in Microsoft outlook using perl-code Yekhande, Seema \(MLITS\) Thu, 01 Jun 2006 00:55:20 -0700 Title: FW: How to save the attachment in Microsoft outlook using perl-code Dear All, I am writing following code to read the latest message in Microsoft outlook. But does anyone knows how to write a code to download the attachment with name given. Please tell me how to save the attachment in particular folder with given name using perl. # create the object use Mail::Outlook; my $outlook = new Mail::Outlook(); # start with a folder my $outlook = new Mail::Outlook('Inbox'); # use the Win32::OLE::Const definitions use Mail::Outlook; use Win32::OLE::Const 'Microsoft Outlook'; my $outlook = new Mail::Outlook(olInbox); # get/set the current folder my $folder = $outlook-folder(); my $folder = $outlook-folder('Inbox'); # get the first/last/next/previous message my $message = $folder-first(); # read the attributes of the current message my $text = $message-From(); $text .= $message-To(); $text .= $message-Cc(); $text .= $message-Bcc(); $text1 = $message-Subject(); $text2 = $message-Body(); print ==$text==$text1==$text2===\n; Thanks, Seema. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
trouble with insert in MS SQL
hi all, haven't worked with this for a while - still, don't remember getting this error message ever ... The code I'm running is below: use Win32::OLE; use Win32::OLE::Const; $db = db1; $srv = mySrv; $uid = usr1; $pwd = usr1pwd; #this is an OLEDB connection to a MS-SQL Database $connStr = PROVIDER=SQLOLEDB;SERVER=$srv;DATABASE=$db;UID=$uid;PWD=$pwd; $conn = Win32::OLE- new(ADODB.Connection) or die Error creating Connection Object\n; $rs = Win32::OLE-new('ADODB.Recordset') or die Error creating Record Set Object\n;; $conn- Open($connStr); $rs-Open('Balance', $connStr, $ado_consts-{adLockOptimistic}); my $Fields = ['ItemId', 'ItemDate', 'ItemAmount', 'ItemComments']; my $Values = [1, '2006-11-29 2:50:01', '12.34', 'insert try 1']; $rs-AddNew($Fields, $Values); # adds a record print \nThis didn't go thru: , Win32::OLE-LastError(), \n if (Win32::OLE-LastError()); $rs-Close(); $conn- Close(); When executing the above I get: This didn't go thru: OLE Exception from ADODB.Recordset: Current Recordset does not support updating. This is a limitation of the provider, or of the selected locktype. When using the code without the $rs-Open( ... line it will complain about executing the AddNew method on a closed object; when adding $rs-Open() with the params above it will issue the error. Any ideas? Thanks, Dan Want to start your own business? Learn how on Yahoo! Small Business. http://smallbusiness.yahoo.com/r-index ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Counting Matches In A Line
Hi Guys, How do I count matches in each line of a foreach loop... Use strict; My ($line,@match_count); My @data = (ALM1;;\Alarm 1\;;FINISH;, ;ALM2;;\Alarm 2\;SCO;FINISH;); Foreach $line (@data) { My $number=0; # Code to count ; in each line Push @match_count, $number; } Print Output: @match_count should eq 9 6; Thanks in advance for any help. Ewen ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Counting Matches In A Line
We need some more information. What is the match condition and how do u find the number of matches? If ur just trying to record the number of something per line so that u can go back and correlate the number to the line, then u can't use foreach. U have to iterate over the array so u can get the offset. for $i (0 .. $#data) { $number = 0 + do_something; $matchcount[$i] = $number; } Now $matchcount[$i] corresponds to the number of matches in $data[$i]. -- REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =-- ...ne cede malis 0100 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Counting Matches In A Line
All I want to do is count the number of ;'s on each line of 15,000'ish lined text file. The first 3 lines look like (FINISH; is the end of 1 line): NEW ANALOGUE; A.PS.19.601; 0; 4;NA; 0;OFF;%;NO; 100.0; 0.0;ANALOGUE CARD #100 INPUT NO 01;FLOAT;FINISH; NEW ANALOGUE; A.PS.19.602; 1; 4;NA; 0;OFF;%;NO; 100.0; 0.0;ANALOGUE CARD #100 INPUT NO 02;FLOAT;FINISH; NEW ANALOGUE; A.PS.19.603; 2; 4;NA; 0;OFF;%;NO; 100.0; 0.0;ANALOGUE CARD #100 INPUT NO 03;FLOAT;FINISH; Basically the file is an export from a very old database and there is not always the same amount of ;'s in each line. I've been given the lovely task of changing the format so that each line in the file can be imported into an access database from a ; delimited file in the correct order. The match condition is number of ; in 1 line Output: found 14 ; in 1,232 lines found 13 ; in 7,456 lines found 12 ; in 2,321 lines I only need total number of lines found. I do not know what the max or min amount of ;'s there can be in one line. Ewen -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Chris Wagner Sent: 05 December 2006 18:50 To: Perl-Win32-Users@listserv.ActiveState.com Subject: Re: Counting Matches In A Line We need some more information. What is the match condition and how do u find the number of matches? If ur just trying to record the number of something per line so that u can go back and correlate the number to the line, then u can't use foreach. U have to iterate over the array so u can get the offset. for $i (0 .. $#data) { $number = 0 + do_something; $matchcount[$i] = $number; } Now $matchcount[$i] corresponds to the number of matches in $data[$i]. -- REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =-- ...ne cede malis 0100 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Counting Matches In A Line
The match condition is number of ; in 1 line Output: found 14 ; in 1,232 lines found 13 ; in 7,456 lines found 12 ; in 2,321 lines my %line_counts; while () { my $semis = tr/;/;/; if ( $semis ) { $line_counts{$semis}++; } else { warn(Bad data - no semis: $_); } # if $semis }# while foreach my $counts ( sort keys %line_counts ) { printf(Found %02d ; in %d lines\n, $line_counts{$counts}, $counts); } run on itself, we get # perl /tmp/ln.pl /tmp/ln.pl Bad data - no semis: while () { Bad data - no semis:if ( $semis ) { Bad data - no semis:} Bad data - no semis:else { Bad data - no semis:} # if $semis Bad data - no semis: Bad data - no semis: }# while Bad data - no semis: foreach my $counts ( sort keys %line_counts ) { Bad data - no semis: } Found 03 ; in 1 lines Found 01 ; in 2 lines Found 01 ; in 3 lines a Andy Bach Internet: [EMAIL PROTECTED] VOICE: (608) 261-5738 FAX 264-5932 Have you noticed that people whose parents did not have children, also tend not to have children? - Robert J. Kolker in sci.math, Re: Genetics and Math-Ability ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Counting Matches In A Line
This: cut here while(DATA) { $cnt=()=$_=~ /;/g; $matches{$cnt}++; } print found $_ ; in $matches{$_} line(s)\n foreach (sort {$b = $a } keys %matches); __DATA__ NEW ANALOGUE; A.PS.19.601; 0; 4;NA; 0;OFF;%;NO; 100.0;0.0;ANALOGUE CARD #100 INPUT NO 01;FLOAT;FINISH; NEW ANALOGUE; A.PS.19.602; 1; 4;NA; 0;OFF;%;NO; 100.0;0.0;ANALOGUE CARD #100 INPUT NO 02;FLOAT;FINISH; NEW ANALOGUE; A.PS.19.603; 2; 4;NA; 0;OFF;%;NO; 100.0;0.0;ANALOGUE CARD #100 INPUT NO 03;FLOAT;FINISH; Just one ; And here are 2 semicolons: ;; cut here Will produce this output: $ perl matches.pl found 14 ; in 3 line(s) found 2 ; in 1 line(s) found 1 ; in 1 line(s) The $cnt=()=$_=~/;/g/ is a TomC trick. Hope this helps Tobias -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of EwenMarshall Sent: Tuesday, December 05, 2006 12:23 PM To: Perl-Win32-Users@listserv.ActiveState.com Subject: RE: Counting Matches In A Line All I want to do is count the number of ;'s on each line of 15,000'ish lined text file. The first 3 lines look like (FINISH; is the end of 1 line): NEW ANALOGUE; A.PS.19.601; 0; 4;NA; 0;OFF;%;NO; 100.0; 0.0;ANALOGUE CARD #100 INPUT NO 01;FLOAT;FINISH; NEW ANALOGUE; A.PS.19.602; 1; 4;NA; 0;OFF;%;NO; 100.0; 0.0;ANALOGUE CARD #100 INPUT NO 02;FLOAT;FINISH; NEW ANALOGUE; A.PS.19.603; 2; 4;NA; 0;OFF;%;NO; 100.0; 0.0;ANALOGUE CARD #100 INPUT NO 03;FLOAT;FINISH; Basically the file is an export from a very old database and there is not always the same amount of ;'s in each line. I've been given the lovely task of changing the format so that each line in the file can be imported into an access database from a ; delimited file in the correct order. The match condition is number of ; in 1 line Output: found 14 ; in 1,232 lines found 13 ; in 7,456 lines found 12 ; in 2,321 lines I only need total number of lines found. I do not know what the max or min amount of ;'s there can be in one line. Ewen ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Counting Matches In A Line
EwenMarshall wrote, on Tuesday, December 05, 2006 2:23 PM : All I want to do is count the number of ;'s on each line of : 15,000'ish lined text file. The first 3 lines look like : (FINISH; is the end of 1 line): : : NEW ANALOGUE; A.PS.19.601; 0; 4;NA; 0;OFF;%;NO; 100.0; : 0.0;ANALOGUE CARD #100 INPUT NO 01;FLOAT;FINISH; : NEW ANALOGUE; A.PS.19.602; 1; 4;NA; 0;OFF;%;NO; 100.0; : 0.0;ANALOGUE CARD #100 INPUT NO 02;FLOAT;FINISH; : NEW ANALOGUE; A.PS.19.603; 2; 4;NA; 0;OFF;%;NO; 100.0; : 0.0;ANALOGUE CARD #100 INPUT NO 03;FLOAT;FINISH; : : Output: : found 14 ; in 1,232 lines : found 13 ; in 7,456 lines : found 12 ; in 2,321 lines I think this is what you want (only slightly tested): my @semis; while (IN) { ++$semis[tr/;/;/]; } The tr/// operator counts all the occurrences of the translated character(s) in $_ (the default), and then you just increment the @semis array at the index of the number of semicolons found to indicate another line with that number of semicolons. Good luck, Joe Joseph Discenza, Senior Programmer/Analyst mailto:[EMAIL PROTECTED] Carleton Inc. http://www.carletoninc.com 574.243.6040 ext. 300 Fax: 574.243.6060 : -Original Message- : From: [EMAIL PROTECTED] : [mailto:[EMAIL PROTECTED] On : To: Perl-Win32-Users@listserv.ActiveState.com : Subject: RE: Counting Matches In A Line : : : I only need total number of lines found. I do not know what : the max or min amount of ;'s there can be in one line. : : Ewen : : -Original Message- : From: [EMAIL PROTECTED] : [mailto:[EMAIL PROTECTED] On : Behalf Of Chris Wagner : Sent: 05 December 2006 18:50 : To: Perl-Win32-Users@listserv.ActiveState.com : Subject: Re: Counting Matches In A Line : : We need some more information. What is the match condition : and how do u find the number of matches? : : If ur just trying to record the number of something per : line so that u can go back and correlate the number to the : line, then u can't use foreach. U have to iterate over the : array so u can get the offset. : : for $i (0 .. $#data) { : $number = 0 + do_something; : $matchcount[$i] = $number; : } : : Now $matchcount[$i] corresponds to the number of matches in $data[$i]. : : : : : : : -- : REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =-- : ...ne cede malis : : 0100 : : ___ : Perl-Win32-Users mailing list : Perl-Win32-Users@listserv.ActiveState.com : To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs : : ___ : Perl-Win32-Users mailing list : Perl-Win32-Users@listserv.ActiveState.com : To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs : ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
RE: Counting Matches In A Line
At 02:39 PM 12/5/2006 -0500, Joe Discenza wrote: The tr/// operator counts all the occurrences of the translated character(s) in $_ (the default), and then you just increment the @semis array at the index of the number of semicolons found to indicate another line with that number of semicolons. Heh, clever, but probably too clever. That will give u an array full of zero's. U can't have sparse arrays in perl. Doing ++$semis{ tr/;/;/ }; would be better. -- REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =-- ...ne cede malis 0100 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Counting Matches In A Line
Chris Wagner wrote: At 02:39 PM 12/5/2006 -0500, Joe Discenza wrote: The tr/// operator counts all the occurrences of the translated character(s) in $_ (the default), and then you just increment the @semis array at the index of the number of semicolons found to indicate another line with that number of semicolons. Heh, clever, but probably too clever. That will give u an array full of zero's. U can't have sparse arrays in perl. Doing ++$semis{ tr/;/;/ }; would be better. Sure you can. The unused/skipped cells will be undef which you can check for on the print. ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Re: Counting Matches In A Line
At 01:33 PM 12/5/2006 -0800, $Bill Luebkert wrote: Sure you can. The unused/skipped cells will be undef which you can check for on the print. undef is also a legal rvalue. Perl autoextends arrays with undef values. So regardless, perl will consider those offsets to exist. Say he had lines with 500 or 1000 semicolons. Perl would autovivify 999 scalars and initialize them to undef values. Like this: D:\backupsperl $a[10] = 5; print scalar @a; ^D 11 If perl supported sparse arrays that would have printed 1. So yeah it would kinda work if u didn't mind the memory hit and having to check for undef array elements. Using a hash is the simpler solution. -- REMEMBER THE WORLD TRADE CENTER ---= WTC 911 =-- ...ne cede malis 0100 ___ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs