Page 1 of 2 12>
Topic Options
#87962 - 2002-09-16 09:10 PM Send E-mail with COM
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 [Confused]

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 Offline
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.
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#87964 - 2002-09-16 10:26 PM Re: Send E-mail with COM
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
You could always use Lonkero's TELNET solution. Unless, of course the TELNET interface to the SMTP mail server has been disabled.
_________________________
There are two types of vessels, submarines and targets.

Top
#87965 - 2002-09-16 10:37 PM Re: Send E-mail with COM
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
actually, the telnet solution has nothing to do with telnet interface.

the solution using telnet, is behaving like smtp server.

like, you can send mail in your own network as your boss to everyone if your net has not disabled internal smtp.
_________________________
!

download KiXnet

Top
#87966 - 2002-09-16 11:17 PM Re: Send E-mail with COM
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11164
Loc: Boston, MA, USA
Lonkero: I did mean the TELNET interface into an SMTP service. Your solution uses TELNET to send certain strings to port 25 of an SMTP Server in order to send an email. However, some email servers have the ability to deny this type of connection while still allowing regular email clients to send email via SMTP.
_________________________
There are two types of vessels, submarines and targets.

Top
#87967 - 2002-09-16 11:21 PM Re: Send E-mail with COM
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, only ability is disable usage of plain text connections.
this means, that even the normal clients using pop3 and such would need to use ssl or similar.

this type of disabling I have not seen used pretty much as normal servers using internet mail connector do not handle mail coming from clients but other smpt servers.
_________________________
!

download KiXnet

Top
#87968 - 2002-09-16 11:33 PM Re: Send E-mail with COM
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Kirk ... hows it going bud ? i think your best bet is to track-down that "registering kixtart" thingy you mentioned earlier .. see if you can find any more info on that ... the port from old OLE to the new COM is very straight-forward. But no good unless you can get past that security patch they put in.

[ 16. September 2002, 23:34: Message edited by: Shawn ]

Top
#87969 - 2002-09-16 11:41 PM Re: Send E-mail with COM
Anonymous
Unregistered


[Embarrassed]

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
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
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
#87972 - 2002-09-17 12:29 AM Re: Send E-mail with COM
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
damn... nameservers crashing all the time! [Mad]

anyway, if you check from the manual the createobject, you see that there is no such thing anymore as olecreate...

it has been replaced with the createobject which supports com.
so, changing your ole-calls to com calls should do the job.
_________________________
!

download KiXnet

Top
#87973 - 2002-09-17 12:44 AM Re: Send E-mail with COM
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
#87974 - 2002-09-17 12:49 AM Re: Send E-mail with COM
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well, I quess it's all about the default object property.

mmm, there was some 2-3 days ago really simple outlook script out in these forums...
_________________________
!

download KiXnet

Top
#87975 - 2002-09-17 11:09 AM Re: Send E-mail with COM
Breaker Offline
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
#87976 - 2002-09-17 11:33 AM Re: Send E-mail with COM
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
kirm,

have you tried that your isp server...

telnet to it's port 25

if it gives you a connection, it might ask for helo-ehlo, but after that write the rcpt to and mail from things with your own internal address and see if it lets the mail come true.

if there is good security, it does not let it, but try.
I don't remember the correct keywords, but they are there in my smtp-mail udf.

if it accepts the addresses post some crap.
_________________________
!

download KiXnet

Top
#87977 - 2002-09-17 04:15 PM Re: Send E-mail with COM
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 Offline
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
_________________________
How to ask questions the smart way <-----------> Before you ask

Top
#87979 - 2002-09-17 10:36 PM Re: Send E-mail with COM
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
#87980 - 2002-09-17 10:39 PM Re: Send E-mail with COM
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
did you get your message to show?

it should need one empty line after the subject...
_________________________
!

download KiXnet

Top
#87981 - 2002-09-17 10:57 PM Re: Send E-mail with COM
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 [Razz]

Top
Page 1 of 2 12>


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

Who's Online
1 registered (Allen) and 382 anonymous users online.
Newest Members
gespanntleuchten, DaveatAdvanced, Paulo_Alves, UsTaaa, xxJJxx
17864 Registered Users

Generated in 0.071 seconds in which 0.027 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