#87962 - 2002-09-16 09:10 PM
Send E-mail with COM
|
Anonymous
Anonymous
Unregistered
|
I read Shawn's script on sending an e-mail with OLE and was really impressed. (But then again Shawn is the king of OLE as I have learned from the past posts) but what about COM. Can it be done?
By the way, is it impossible to send an e-mail with Service pack 2 in place? I got the impression that it is impossible. Radimus posted a solution (I think). It was to register Kixtart. We are service packed to the hilt here and so any e-mailing would have to get past the patches. As far as a third party solution for e-mailing is concerned, I'd like to avoid it. They are as cheap as a $2 whore here (excuse the euphemism) and I doubt they would spring for said solutions. Any thoughts on this?
Kirk
P.S. Sorry to post here but I tried to post on the original thread and it wouldn't work. I think it may be closed although nothing appeared to indicate this.
|
Top
|
|
|
|
#87963 - 2002-09-16 09:34 PM
Re: Send E-mail with COM
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
to COM, you have to COM something. The problem is that SP2 kills the automated COM mail routines... unless someone has hacked their way around it.
Many use BLAT, and there was even a post using telnet to post directly to smtp port.
I have a the script log events that would have been mailed to me, and a admin app for me that parses, looking for new events...
your solution is kind of specific as to what you would like to do.
|
Top
|
|
|
|
#87969 - 2002-09-16 11:41 PM
Re: Send E-mail with COM
|
Anonymous
Anonymous
Unregistered
|
Sorry Guys, I should have been more specific. I use Kixtart (Version 4.11) to run back ups on our network. We have Win9x and 2k boxes. I am sending the results of the backups to a text file (Log) but I want the script to be able to e-mail me if a backup Errors. That way I can make sure the universe is unfolding as it should (To quote a former Prime Minister of our large and somewhat cold country.) The Telnet solution sounds somewhat intriguing but the thing is that our e-mail is supplied by a local ISP. We don't have Exchange or any other sort of internal e-mail. By the way, the network is P2P. Yeah, I know, but like I said they are extremely cheap here.
Kirm
|
Top
|
|
|
|
#87970 - 2002-09-16 11:47 PM
Re: Send E-mail with COM
|
Anonymous
Anonymous
Unregistered
|
Hi Shawn
Good to hear from you again.
So if I understand the situation correctly, If I register Kixtart with Radimus' solution then Windows will let Kixtart e-mail me. I'm going to try it and I'll post the results. This could take a while but I shall return.
Kirm
|
Top
|
|
|
|
#87971 - 2002-09-17 12:12 AM
Re: Send E-mail with COM
|
Anonymous
Anonymous
Unregistered
|
Back again
Used radimus' script to register Kixtart...with some changes for my editor
code:
$kix="HKEY_CLASSES_ROOT\.KIX" $kixautofile="HKEY_CLASSES_ROOT\KIX_auto_file" AddKey("$kix") WriteValue("$kix","","KIX_auto_file",REG_SZ) AddKey("$kixautofile") WriteValue("$kixautofile","","KiXtart Script",REG_SZ) WriteValue("$kixautofile","EditFlags","0",REG_SZ) AddKey("$kixautofile\DefaultIcon") WriteValue("$kixautofile\DefaultIcon","","%windir%\system32\SHELL32.dll,21",REG_EXPAND_SZ) AddKey("$kixautofile\shell") WriteValue("$kixautofile\shell","","Run",REG_SZ) AddKey("$kixautofile\shell\Edit") AddKey("$kixautofile\shell\Edit\command") WriteValue("$kixautofile\shell\Edit\command","","C:\Program Files\RWK Systems\KiXscripts Editor\KiXscriptEditor.exe %1",REG_EXPAND_SZ) AddKey("$kixautofile\shell\Run") AddKey("$kixautofile\shell\Run\command") WriteValue("$kixautofile\shell\Run\command","","%windir%\kix32.exe %1",REG_EXPAND_SZ)
This should be OK, right? I made allowances for my Kixtart editor.
Now running Shawn's OLE e-mail.
code:
Break on CLS $recipient = "kirk@@volvotruckcentre.com" ; use double @@'s $subject = "This is the subject" $message = "This is the message body" $outlook = OLECreateObject("outlook.application") $namespace = Val("&" + OLECallFunc($outlook, "getnamespace", "s", "MAPI")) $= OLECallFunc($namespace, "logon") $mailitem = Val("&" + OLECallFunc($outlook, "createitem", "s", "0")) $recipients = Val("&" + OLEGetProperty($mailitem, "recipients")) $ = OLECallFunc($recipients, "add", "s", "$recipient") $ = OLEPutProperty($mailitem, "subject", "s", "$subject") $ = OLEPutProperty($mailitem, "body", "s", "$message") $ = OLECallFunc($mailitem, "send") $ = OLECallFunc($namespace, "logoff" ) $ = OLEReleaseObject($recipients) $ = OLEReleaseObject($mailitem) $ = OLEReleaseObject($outlook) Exit
The Code errors on this line:
code:
$namespace = Val("&" + OLECallFunc($outlook, "getnamespace", "s", "MAPI"))
It's strange because running throught the debugger it displays this line:
$outlook = OLECreateObject("outlook.application")
and then repeats this part:
("outlook.application")
It's almost like it doesn't recognize the OLE reference. This may be a matter of it not allowing Outlook to be used by Kixtart in spite of the registration.
Kirk
P.S. I'm doing it in OLE first to see if I can get it working and then I'll translate it into COM.
|
Top
|
|
|
|
#87973 - 2002-09-17 12:44 AM
Re: Send E-mail with COM
|
Anonymous
Anonymous
Unregistered
|
You can say that again Lonkero. OLE isn't available anymore in Kixtart 4.11. So I COMed it. I read Shawns primer on COM (Should have done this from the beginning) Anyway this works without an error:
code:
Break on
$recipient = "kirk@@volvotruckcentre.com" ; use double @@'s $subject = "This is the subject" $message = "This is the message body" $outlook = CreateObject("outlook.application") ?"Outlook = " + $outlook $outlook.visible=1 If @ERROR <> 0 ?"Error" Else ?"Outlook is running" EndIf
It outputs Outlook = Outlook Outlook is running
Strange huh?
The problem is that Outlook isn't running. It doesn't show up in task manager, anyway. I suspect I'm running up against Outlook security.
Any thoughts?
|
Top
|
|
|
|
#87975 - 2002-09-17 11:09 AM
Re: Send E-mail with COM
|
Breaker
Hey THIS is FUN
Registered: 2001-06-15
Posts: 268
Loc: Yorkshire, England
|
What version of Outlook are you trying to use? If it's 98+ with the Outlook security patch applied, then programmatic access to Outlook is disabled. There's a lot of stuff on MSDN about how to get around this, but unless you have an Exchange environment and a helpful Exchange admin, you are still going to have Outlook asking you whether to allow access to email every time your script (or any other application) runs.
I'll dig out a couple of links and post them here later today, but basically the fix was to create a new public folder in the Exchange organisation, download a custom form from M$, make a couple of reg hacks on the machines that would run the script, or application, or whatever, and then Robert's your father's brother. Trouble is, you'll need a lot of rights on your Exchange box and your client machines to do it.
Back later with links...
_________________________
================================================ Breaker
|
Top
|
|
|
|
#87977 - 2002-09-17 04:15 PM
Re: Send E-mail with COM
|
Anonymous
Anonymous
Unregistered
|
To reply to everyone who posted: We don't have internal e-mail. No exchange server. Our E-mail provider cannot be telneted to and we are using Outlook 2000 or 2002 with all the latest security patches. Why does Outlook have to be used to send an e-mail? There has to be another way and I'll find it. The tough part is is has to be free.
Kirm
P.S. I'm not really sure of my Telneting ability. If some one could confirm I would appreciate it. I open up a prompt and type telnet. Then I type:
open pop.interbaun.com:25
This comes back saying it couldn't open a connection to the host.
|
Top
|
|
|
|
#87978 - 2002-09-17 04:35 PM
Re: Send E-mail with COM
|
Radimus
Moderator
Registered: 2000-01-06
Posts: 5187
Loc: Tampa, FL
|
What you need to realize is that the security patches for outlook were designed to specifically prevent what you want to do...
you can still COM it, but Outlook will pop up warning messages on the desktop asking "do you want to do this??"
telnet to your smtp mailserver, not the pop server
|
Top
|
|
|
|
#87979 - 2002-09-17 10:36 PM
Re: Send E-mail with COM
|
Anonymous
Anonymous
Unregistered
|
Hello everyone
I've found out a bunch of stuff so I though I'd share. (It's nothing that anybody doesn't already know) Radimus is correct about the security patches. What I'd like to know is how do all these low quality virii, which seem to come out every week, use outlook's address book to send themselves to other people. Hell, that Klez virus could not only send itself to people but it would spoof the senders address.
SMTP does work with our ISP. I was just doing it incorrectly. I found that out through Lonkero's telnet script. The only part of his script that wouldn't work after a few mods was that the from address had to be a valid e-mail and the body wasn't sent. I'm sure these are peculiarities with our mail server and not Lonkero's UDF. Then again, I believe that the subject and body must be wrapped in qoutes. If I sent a single word subject it worked but multiple words and nothing was seen in the subject line after the e-mail arrived. Kudos to Lonkero for his masterful scripting and all round knowledgableness of the SMTP world.
Here is the modified code I used(and it did work...at least partly):
code:
SendMail("199.185.130.23","kirk@@volvotruckcentre.com","kirk@@volvotruckcentre.com","test","I am just testing... nothing more nothing less") Function SendMail($server,$from,$to,$subject,$message) If (2>Len($server) OR 2>Len($from) OR 2>Len($to) OR 2>Len($subject) OR 2>Len($message)) Exit(13) EndIf Run '%comspec% /c start "SendMail ' + $server + '" /MIN telnet $server 25' Sleep 15 If SetFocus ("SendMail " + $server) <> 0 Exit(53) EndIf Sleep 2 If SetFocus ("SendMail "+$server) <> 0 Exit(53) EndIf $r = ""+ SendKeys("MAIL FROM:$from{ENTER}") Sleep 1 $r = $r +","+ SendKeys("RCPT TO:$to{ENTER}") Sleep 1 $r = $r +","+ SendKeys("DATA{ENTER}") Sleep 1 $r = $r +","+ SendKeys("Subject: $subject{ENTER}") Sleep 1 $r = $r +","+ SendKeys("$message{ENTER}") $r = $r +","+ SendKeys(".{ENTER}") Sleep 1 $r = $r +","+ SendKeys("QUIT{ENTER}") $SendMail = $r Exit(0) EndFunction
Once again this is Lonkero's code. I have just modified it slightly.
I have found a work around for my problem too. I just downloaded Blat and read the license agreement and it appears to be freeware. I tinkered with it and was amazed at how well it worked. So that is the route I will take. I'm just not so sure it will work with 9x
Thank you everyone for your help.
|
Top
|
|
|
|
#87981 - 2002-09-17 10:57 PM
Re: Send E-mail with COM
|
Anonymous
Anonymous
Unregistered
|
Yep I got it to work and you were right Lonkero it needed another space. Here's the line I changed:
$r = $r +","+ SendKeys("Subject: $subject{ENTER}{ENTER}")
I just entered another {ENTER}. It works great now Except it still doesn't show anything in the "to" and "from" boxes. Actually in the "to" box it says: undisclosed-recipients:
Very interesting! This could be the next great spamming tool. Just what the world needs
|
Top
|
|
|
|
Moderator: Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart
|
1 registered
(Allen)
and 382 anonymous users online.
|
|
|