Page 1 of 1 1
Topic Options
#208386 - 2014-01-24 10:52 PM modified input text file - doesn't work for the addition
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
I have a wkix32 script that works great. It sends e-mails with different attachments for different doctors. I have a text file with the doctor name and e-mail addresses in it. I added a new doctor, but it will not e-mail the doctor. He is the only one with an internal e-mail address. I have tested with my e-mail (internal as well) and the same thing happens.

How can I add him with his internal exchange e-mail address? The following is a sample of the text file:
 Quote:

[Docs]
names=DOC1#DOC2
[DOC1]
e-mail=DOC1fnamelastname@shannonhealth.org
[DOC2]
email=DOC2fname.lastname@suddenlink.net


The script:
 Code:
$home = "\\server1\dir2\dir2"
;$FSO = createobject("Scripting.FileSystemObject"


$thismo = @monthno -1
IF $thismo = 0
  $month = "12"
ELSE
  IF $thismo > 9
    $month = CSTR($thismo)
  ELSE
    $month = "0" + CSTR($thismo)
  ENDIF
ENDIF
$year = IIf(@MONTHNO = 1, @YEAR -1, @YEAR)

;open log file
IF Open(2, "\\server2\dir1\dir2\log$month.txt",5) = 0
  $w = WriteLine( 2 , "docmailer2010.kix started at " +@DATE + " - " + @TIME + Chr(13) + Chr(10) )
  ELSE
  BEEP
  ? "Error opening log file: [" + @ERROR + "]"
  sleep 5
  EXIT
ENDIF


;main program loop

$rc = SetOption("NoMacrosInStrings","On")
$rc = SetOption("NoVarsInStrings","On")

$Docs = Split(ReadProfileString("\\server2\dir1\dir2\docmailer2010.txt","Docs","Names"),"#")
? "Elements in Docs Array: "+UBound($docs)

If UBound($docs)>=0
	$Root = CreateObject("Outlook.Application")
	$Session = $Root.GetNamespace("MAPI")
	$DefaultProfile = Outlook
	$Session.Logon($DefaultProfile)	
	$Folder = $Session.GetDefaultFolder(olFolderInbox)
	$Folder.Display
? "Outlook Creation: "+@Error
	For Each $Doc in $Docs
? "Doc: "+$Doc
		$docemail = ReadProfileString("\\server2\dir1\dir2\docmailer2010.txt", $doc, "Email")
? "Email: "+$docemail
		If Len($docemail)
			$MailItem = $Root.CreateItem(0)
? "Root Creation: "+@Error
			$MailItem.Importance = 1
			$MailItem.Subject = "Reports  -  !!! DO NOT REPLY !!!"
			$MailItem.Sender = "sender@company.org"
			$MailItem.To = $docemail
			$MailItem.Body = "!!! DO NOT REPLY - EMAIL IS NOT MONITORED.  FOR ASSISTANCE CALL 657-5041 !!!"
			$Attachments = DirList($home+"\"+$doc+"\(current month)",2)
? "Elements in Attachment Array: "+UBound($attachments)
			If UBound($Attachments)>=0
				For Each $Attachment in $Attachments
					$MailItem.Attachments.Add($Attachment)
? "Attachment: "+@Error
				Next
			Endif
			$MailItem.Send
? "Send: "+@Error
	Endif
	Next
	$Root = 0
Endif



I do have the DirList UDF at the bottom of the script.
This works great unless I am trying to send to an internal e-mail address. I am using the full e-mail address.

Top
#208387 - 2014-01-24 11:04 PM Re: modified input text file - doesn't work for the addition [Re: Karon]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
I see there are some error checks in the script...Are any errors shown when the script is run?
Top
#208388 - 2014-01-24 11:20 PM Re: modified input text file - doesn't work for the addition [Re: ShaneEP]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
Nope, just shows his name, e-mail (no address) and then goes to the next one and proceeds normally for all the rest.

And can I send the error output to a file and how?


Edited by Karon (2014-01-24 11:43 PM)

Top
#208389 - 2014-01-25 12:11 AM Re: modified input text file - doesn't work for the addition [Re: Karon]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
The easiest way would be to place this line at the beginning of the script.

 Code:
$nul = RedirectOutput("C:\path\to\file\log.txt")


Essentially this will cause any message that normally displays on the console, to be instead saved to the file.

Top
#208390 - 2014-01-25 12:13 AM Re: modified input text file - doesn't work for the addition [Re: ShaneEP]
ShaneEP Moderator Offline
MM club member
*****

Registered: 2002-11-29
Posts: 2127
Loc: Tulsa, OK
But if it's not displaying the actual email address, then it's not getting it from the file.

Try changing in the ini file......

e-mail=
to
email=

It shouldn't have the dash (-) in email.


Edited by ShaneEP (2014-01-25 12:14 AM)

Top
#208392 - 2014-01-25 06:42 PM Re: modified input text file - doesn't work for the addition [Re: ShaneEP]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
bet that's it ;\)
_________________________
!

download KiXnet

Top
#208407 - 2014-01-27 02:46 PM Re: modified input text file - doesn't work for the addition [Re: Lonkero]
Karon Offline
Getting the hang of it

Registered: 2009-07-16
Posts: 87
Loc: Texas
That's it!! I removed the "-" and it works!! Sometimes it just takes a second set of eyeballs to find the little things! Thanks so much!!
Top
#208408 - 2014-01-27 04:54 PM Re: modified input text file - doesn't work for the addition [Re: Karon]
BradV Offline
Seasoned Scripter
****

Registered: 2006-08-16
Posts: 687
Loc: Maryland, USA
I've found that so often myself. Your mind knows what it should be and so doesn't actually see what is there! \:\)
Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
1 registered (Henriques) and 2516 anonymous users online.
Newest Members
fgarcia, Viginette, ManuvdWielNL, Sir_Barrington, batdk82
17889 Registered Users

Generated in 0.064 seconds in which 0.028 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org