Discussion:
Blat DLL 3.1.1 returns errors 1 or 12
(too old to reply)
letitbitas
2013-03-14 19:20:59 UTC
Permalink
Hello,

I have downloaded the last version of Blat a few days ago. When I'm using it with batch file, everything works ok.
However I need to pass command to blat from AutoHotkey_L script. I have found appropriate script on the AutoHotkey forum here: http://www.autohotkey.com/board/topic/9845-blat-dll-usage/page-3?hl=mail%20sending

The script is marked as tested with blat.dll version 2.6.2. However, this does not work with 3.1.1: dll returns codes 1 or 12 as the best results. Because there is no debug information for dll, its not easy determine why. Could you please help me with passing data to the blat.dll correctly?

Thanks in advance for any support.

Here is the AHK code:

; setting variables:

Text = %A_ScriptDir%\Test.txt
eMail=***@yandex.ru
subj=-s "Test Blat"
user=***@yandex.ru
pass=-pw somepassword
server=-server smtp.yandex.ru:587
x=-x "X-Header-Test: Can Blat do it? Yes it Can!"

; Joining variables to Blat_String:

Blat_String = %Text% -to %eMail% -f %user% -u %user% %pass% %subj% %server% %x%

; Calling Blat.dll:

Blat_DLL:=DllCall("blat.dll\Send","Str",Blat_String)
msgbox %Blat_DLL% ; 0 => OK

ExitApp

Here is the content of Blat_String before passing to dll:

C:\Documents and Settings\Apsauga\Desktop\blat311\full\Testas.txt -to ***@yandex.ru -f ***@yandex.ru -u ***@yandex.ru -pw somepassword -s "Test Blat" -server smtp.yandex.ru:587 -x "X-Header-Test: Can Blat do it? Yes it Can!"

blat.dll returned code 12 with this. Could you please write, what exactly should be content of Blat_String in this case?
ykai
2013-03-14 21:01:51 UTC
Permalink
Post by letitbitas
C:\Documents and Settings\Apsauga\Desktop\blat311\full\Testas.txt -to
-s "Test Blat" -server smtp.yandex.ru:587 -x "X-Header-Test: Can Blat do it?
Yes it Can!"
Maybe you should surround the file name (which has blanks inside) with
quotes, like you did with the args to -s and -x?!
--
Kai
letitbitas
2013-03-14 21:41:16 UTC
Permalink
Actually, I have checked this version. I have added quotes, but this does not work, still error 12
Post by ykai
Post by letitbitas
C:\Documents and Settings\Apsauga\Desktop\blat311\full\Testas.txt -to
-s "Test Blat" -server smtp.yandex.ru:587 -x "X-Header-Test: Can Blat do it?
Yes it Can!"
Maybe you should surround the file name (which has blanks inside) with
quotes, like you did with the args to -s and -x?!
--
Kai
Tim Musson
2013-03-14 23:42:09 UTC
Permalink
Hey letitbitas,

On Thursday, March 14, 2013 at 3:20:59 PM you wrote

l> C:\Documents and Settings\Apsauga\Desktop\blat311\full\Testas.txt
l> -to ***@yandex.ru -f ***@yandex.ru -u ***@yandex.ru
l> -pw somepassword -s "Test Blat" -server smtp.yandex.ru:587 -x
l> "X-Header-Test: Can Blat do it? Yes it Can!"

Are you sure this works like this with blat.exe? I noticed you already
mentinoed the msg body file was surrounded with quotes, so that should
have solved one problem.

The error you are getting seems to indicate a connection problem,
which makes sense to me. Port 587 is very likely to require SSL/TLS
support (encrypted/secure connection), which Blat does not directly
support. There are 3rd party programs to make this work, such as
stunnel from stunnel.org.

Search the list archives for lots of other posts that cover this.
--
Tim Musson
Flying with The Bat! eMail v5.2.2
Hang up and drive.
letitbitas
2013-03-15 12:27:17 UTC
Permalink
Hello Tim,

Thank you for your answer.

1) The port 587 on the yandex mail service is open port, like port 25 and doesn't requires SSL. I have checked this port before testing dll version of my script, everything is working. Here is script AHK with blat.exe. I have wrote it specially the same structure, like script with blat.dll:

Text = "%A_ScriptDir%\Copy of Test.txt"
eMail=***@yandex.ru
subj=-s "Test Blat"
user=***@yandex.ru
pass=-pw somepassword
server=-server smtp.yandex.ru:587
x=-x "X-Header-Test: Can Blat do it? Yes it Can!"
debug=-debug -log blat.log -timestamp
Blat_String = %Text% -to %eMail% -f %user% -u %user% %pass% %subj% %server% %debug% %x%
FileAppend, `n%Blat_String%, Test.txt ;lets write string content to the file for debug

RunWait, blat.exe %Blat_String%, , Hide UseErrorLevel
Tooltip, %A_LastError% ;lets write string content to the file for debug
Sleep, 5000
ExitApp

Here is the content of the Blat_String taken from file Test.txt:

"C:\Documents and Settings\Apsauga\Desktop\blat311\full\Copy of Test.txt" -to ***@yandex.ru -f ***@yandex.ru -u ***@yandex.ru -pw somepassword -s "Test Blat" -server smtp.yandex.ru:587 -debug -log blat.log -timestamp -x "X-Header-Test: Can Blat do it? Yes it Can!"

I have received all test messages sent by this script. And, of course, I have read this forum concerning mentioned problem. Its strange, but script with dll does not like to work :)

Can I download somewhere blat.dll v 2.6.2? It was marked like tested with AHK, so I can check it again with current and previous versions of AHK and determine the problem.
Tim Musson
2013-03-15 13:17:57 UTC
Permalink
Hey letitbitas,

On Friday, March 15, 2013 at 8:27:17 AM you wrote

l> I have received all test messages sent by this script. And, of
l> course, I have read this forum concerning mentioned problem. Its
l> strange, but script with dll does not like to work :)

Very interesting. I don't know why it wouldn't be working.

l> Can I download somewhere blat.dll v 2.6.2? It was marked like
l> tested with AHK, so I can check it again with current and previous
l> versions of AHK and determine the problem.

Sent v262 PM. Please let us know if it works.
--
Tim Musson
Flying with The Bat! eMail v5.2.2
Procrastinate Now!
Mike Mattos
2013-03-15 16:40:51 UTC
Permalink
Just a though, but can you actually call dll's from scripts? I know there
is a different method to call dll's than call exe's withing programming
languages.



MIke



From: ***@yahoogroups.com [mailto:***@yahoogroups.com] On Behalf Of Tim
Musson
Sent: March-15-13 09:18
To: letitbitas
Subject: Re: [blat] Re: Blat DLL 3.1.1 returns errors 1 or 12





Hey letitbitas,

On Friday, March 15, 2013 at 8:27:17 AM you wrote

l> I have received all test messages sent by this script. And, of
l> course, I have read this forum concerning mentioned problem. Its
l> strange, but script with dll does not like to work :)

Very interesting. I don't know why it wouldn't be working.

l> Can I download somewhere blat.dll v 2.6.2? It was marked like
l> tested with AHK, so I can check it again with current and previous
l> versions of AHK and determine the problem.

Sent v262 PM. Please let us know if it works.
--
Tim Musson
Flying with The Bat! eMail v5.2.2
Procrastinate Now!





[Non-text portions of this message have been removed]
Grinkevicius Vilius
2013-03-15 21:39:00 UTC
Permalink
Hello Mike,

No problem, AutoHotkey supports dll calling from script.
Just a though, but can you actually call dll's from scripts?  I know there
is a different method to call dll's than call exe's withing programming
languages.
MIke
Musson
Sent: March-15-13 09:18
To: letitbitas
Subject: Re: [blat] Re: Blat DLL 3.1.1 returns errors 1 or 12
Hey letitbitas,
l> I have received all test messages sent by this script. And, of
l> course, I have read this forum concerning mentioned problem. Its
l> strange, but script with dll does not like to work :)
Very interesting. I don't know why it wouldn't be working.
l> Can I download somewhere blat.dll v 2.6.2? It was marked like
l> tested with AHK, so I can check it again with current and previous
l> versions of AHK and determine the problem.
Sent v262 PM. Please let us know if it works.
--
Tim Musson
Flying with The Bat! eMail v5.2.2
Procrastinate Now!
[Non-text portions of this message have been removed]
------------------------------------
--
  http://www.blat.net
Yahoo! Groups Links
------------------------------------
--
Homepage:
http://www.blat.net
letitbitas
2013-03-15 12:41:01 UTC
Permalink
Hello Tim Again,

I forgot to note, that for dll in this case does not matter, is the name of file surrounded in quotes, or not. Any case it returns 12. I have added a space before the name of file too, but unsuccessful.

But you are completely right, the last my scrip with blat.exe works only if file name is surrounded in quotes.
Chip
2013-03-15 14:16:07 UTC
Permalink
<snipped>
Post by letitbitas
Blat_DLL:=DllCall("blat.dll\Send","Str",Blat_String)
<snipped>




Try changing the above line to look like this:

Blat_DLL:=DllCall("blat.dll\SendA","Str",Blat_String)


Please note the letter A after the word Send.
--
Chip
letitbitas
2013-03-15 23:39:58 UTC
Permalink
Hello Chip, Mike and Tim,

Thanks for your answers. Here is my comments:

- Mike, its no problem to call dll from AutoHotkey scripts, AHK supports it. Except in this case, of course :)

- Chip, no results with your suggested code, still returns "12"

- Tim, I have checked dll v2.6.2. Here is the facts:

Today I have installed legacy version of AutoHotkey (1.048.05) on the fresh machine and tested it with Blat.dll v 2.6.2 and blat dll v3.1.1

Code example (AHK):

Blat_DLL:=DllCall("blat.dll\Send","str","Testas.txt -t ***@yandex.ru -s test -f ***@yandex.ru -server smtp.yandex.ru:587 -u ***@yandex.ru -pw somepasword")


In AHK_L, returns "12" immediately after script is started. Probably, this means that data is rejected by dll from beginning.

In AHK v1.048.05 blat dll returns "0". Test mail is successfully delivered to recipient.

It looks, that problem is the way, how AHK communicates with dll.

Because of this I like to cancel my support inquiry here and will pass this issue to AHK support forum :)

Thank you very much for your support.
Have nice weekend.
Chip
2013-03-16 00:55:34 UTC
Permalink
Post by letitbitas
Today I have installed legacy version of AutoHotkey (1.048.05) on the
fresh machine and tested it with Blat.dll v 2.6.2 and blat dll v3.1.1
Blat_DLL:=DllCall("blat.dll\Send","str","Testas.txt -t
In AHK_L, returns "12" immediately after script is started. Probably, this
means that data is rejected by dll from beginning.
In AHK v1.048.05 blat dll returns "0". Test mail is successfully delivered to recipient.
It looks, that problem is the way, how AHK communicates with dll.
Because of this I like to cancel my support inquiry here and will pass
this issue to AHK support forum :)
Thank you very much for your support.
Have nice weekend.
I just downloaded the source for AutoHotKey (v1.0.48.05) to see about
debugging through the code and figure out a solution. The source is from
September 2009, which might mean nobody is actively maintaining the program.

I should have an answer later this evening.

Chip
Chip
2013-03-16 01:53:11 UTC
Permalink
Post by Chip
Post by letitbitas
Today I have installed legacy version of AutoHotkey (1.048.05) on the
fresh machine and tested it with Blat.dll v 2.6.2 and blat dll v3.1.1
Blat_DLL:=DllCall("blat.dll\Send","str","Testas.txt -t
In AHK_L, returns "12" immediately after script is started. Probably,
this means that data is rejected by dll from beginning.
In AHK v1.048.05 blat dll returns "0". Test mail is successfully delivered to recipient.
It looks, that problem is the way, how AHK communicates with dll.
Because of this I like to cancel my support inquiry here and will pass
this issue to AHK support forum :)
Thank you very much for your support.
Have nice weekend.
I just downloaded the source for AutoHotKey (v1.0.48.05) to see about
debugging through the code and figure out a solution. The source is from
September 2009, which might mean nobody is actively maintaining the program.
I should have an answer later this evening.
I just ran the program against my 32-bit (Win32) copy of blat.dll, and AHK
reported "0" in the pop-up window.

Running AHK program with the 64-bit blat.dll does not work. The pop-up
window has nothing in it.

What we need to know is which build of blat.dll v3.1.1 did you download, and
where did you put the .dll? Win32 build? Win98 build? x64 build?
--
Chip
Chip
2013-03-16 02:13:34 UTC
Permalink
I downloaded the installer for AutoHotKey_L, which turned out to be 64-bit
Unicode version of AutoHotKey. I then copied the 64-bit blat.dll version
3.1.1 to the same directory where AutoHotKey was installed, and everything
is working properly. My test emails are sent, and blat.dll returns a zero
to indicate a successful completion.


This is what I put into the AutoHotKey.AHK file:

^!b::
; Calling Blat.dll:

Blat_DLL:=DllCall("blat.dll\SendW","Str","C:\Users\Chip\missions.txt -to
myself -s Test -superdebug -log R:\blat.txt")
msgbox %Blat_DLL% ; 0 => OK

ExitApp



Please notice the letter W after the word Send, to tell the 64-bit Unicode
AutoHotKey to use the Unicode interface in blat.dll. This works, anything
else does not. The ^!b is to Ctrl-Alt-B to invoke blat.dll.
--
Chip
letitbitas
2013-03-16 16:41:24 UTC
Permalink
Hello Chip

Its working on 32bit Unicode AHK version too. Thanks a lot! Really great job!

Vilius
Post by Chip
Blat_DLL:=DllCall("blat.dll\SendW","Str","C:\Users\Chip\missions.txt -to
myself -s Test -superdebug -log R:\blat.txt")
msgbox %Blat_DLL% ; 0 => OK
ExitApp
Please notice the letter W after the word Send, to tell the 64-bit Unicode
AutoHotKey to use the Unicode interface in blat.dll. This works, anything
else does not. The ^!b is to Ctrl-Alt-B to invoke blat.dll.
--
Chip
Continue reading on narkive:
Loading...