Jump to content
Sign in to follow this  
CodyBarrett

_INetSmtpMail = @Error 50 [ POSTPONED ]

Recommended Posts

CodyBarrett

i am making a mail client... i dislike outlook, and my hotmail takes too long on dialup... so yeah i did some seasrching and i put this together... BUT! it seems i cannot send it the error code i get is 50, anyidears?

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#include <File.au3>
#include <Misc.au3>
#include <Array.au3>
#include <String.au3>
#include <INet.au3>
#Include <GuiEdit.au3>
#include <EditConstants.au3>
#include <ButtonConstants.au3>

Opt ('GUIoneventmode',1)

$Sign_In = GUICreate (' B-Mail Sign In...',200,200,-1,-1,-1,138)
GUICtrlCreateLabel ('Please Sign In...',10,10,100,20)
$Account_Input = GUICtrlCreateInput ('AddressHere@Example.com',10,30,180,20)
$Password_Input = GUICtrlCreateInput ('Password',10,60,180,20,$ES_PASSWORD)
$Log_On_Button = GUICtrlCreateButton ('Log On',50,100,100,30)
$Log_On_Cancel_Button = GUICtrlCreateButton ('Cancel',50,140,100,20)


$GUI = GUICreate ('Bob-Email', 400,600)
GUICtrlCreateLabel ('To :',10,15,60,20)
$To_Input = GUICtrlCreateInput ('username@Example.com',60,10,270,20)
GUICtrlCreateLabel ('From :',10,45,60,20)
$From_Input = GUICtrlCreateInput (GUICtrlRead ($Account_Input),60,40,270,20)
GUICtrlCreateLabel ('Subject :',10,75,60,20)
$Subject_Input = GUICtrlCreateInput ('Subject',60,70,270,20)
$Send = GUICtrlCreateButton ('Send',340,10,50,80)
$Main = GUICtrlCreateEdit ('',10,130,380,460,2101248)
GUICtrlCreateLabel ('Attach :',10,105,60,20)
$Attachment_Input = GUICtrlCreateInput ('',60,100,180,20)
$Include_Yes = GUICtrlCreateRadio ('Yes',250,100,40,20)
$Include_No = GUICtrlCreateRadio ('No',300,100,40,20)
$Browse = GUICtrlCreateButton ('Browse',340,100,50,20)
$AccountName = 0
$AccountPassword = 0


GUICtrlSetOnEvent ($Browse,'Browse')
GUICtrlSetOnEvent ($Include_Yes,'Attach')
GUICtrlSetOnEvent ($Include_No,'Dettach')
GUICtrlSetOnEvent ($Send,'_Send')
GUICtrlSetOnEvent ($Log_On_Button,'LogOn')
GUICtrlSetOnEvent ($Log_On_Cancel_Button,'_exit')
GUISetOnEvent ($GUI_EVENT_CLOSE,'_exit',$Sign_In)
GUISetOnEvent ($GUI_EVENT_CLOSE,'_exit',$GUI)
GUICtrlSetState ($Include_No,$GUI_CHECKED)
GUICtrlSetState ($Browse,$GUI_DISABLE)
GUICtrlSetState ($Attachment_Input,$GUI_DISABLE)
GUISetState (@SW_SHOW,$Sign_In)
GUISetState (@SW_HIDE,$GUI)

While 1
    
    Sleep (100)

WEnd

Func Attach ()
    
    GUICtrlSetState ($Attachment_Input,$GUI_ENABLE)
    GUICtrlSetState ($Browse,$GUI_ENABLE)
    
EndFunc

Func Browse ()
    
    $File = FileOpenDialog ('Browse...',@MyDocumentsDir,' All (*.*)',15,'',$GUI)
    
    If $File = @error Then GUISetState (@SW_SHOW,$GUI)
        
    GUICtrlSetData ($Attachment_Input,$File)
    
EndFunc

Func Dettach ()
    
    GUICtrlSetState ($Attachment_Input,$GUI_DISABLE)
    GUICtrlSetState ($Browse,$GUI_DISABLE)
    
EndFunc

Func LogOn ()
    
    $AccountName = GUICtrlRead ($Account_Input)
    $AccountPassword = GUICtrlRead ($Password_Input)
    GUICtrlSetData ($From_Input,$AccountName)   
    GUISetState (@SW_HIDE,$Sign_In)
    GUISetState (@SW_SHOW,$GUI)
    
EndFunc

Func _Send ()
    $To = GUICtrlRead ($To_Input)
    $Subject = GUICtrlRead ($Subject_Input)
    $Body = StringSplit (GUICtrlRead ($Main), @CRLF)
    $Response = _INetSmtpMail ('Live.com', $AccountName, $AccountName , $To, $Subject)
    
    If $Response = 1 Then
        
        MsgBox (0, "Success!", "Mail sent")
        
    Else
        
        MsgBox (0, "Error!", "Mail failed with error code " & @error)
        
    EndIf
    
EndFunc

Func _exit ()
    
    Exit

EndFunc
Edited by CodyBarrett

Share this post


Link to post
Share on other sites
Richard Robertson

I believe Hotmail disabled the mail access except through webmail.

Share this post


Link to post
Share on other sites
Valuater

I created an email at gmail and was sending SMTP in only 10 minutes.

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites
Richard Robertson

I can confirm that Gmail works for SMTP.

Share this post


Link to post
Share on other sites
CodyBarrett

alright.... so i am VERY new to internet functions of autoit, and would like to understand HOW exactly these work and not just to be able to program it in (latter would be usefull also) so your saying hotmail doesnt work with _inetsmtpmail() but GMAIL does? thats very inconveinient.... while i was searching google i found a CMD command that sends email, but not every computer has that specific Batch file.

PS

so inconclusion when i use _inetsmtpmail() can i send TO a hotmail account or not even use it sending, also would the error '50' be why?

EDIT

alright ive tried my Gmail account and uhhh i still get ERROR = 50.. about 20-30 seconds after i try and send. what am i missing?

Edited by CodyBarrett

Share this post


Link to post
Share on other sites
AdmiralAlkex

alright.... so i am VERY new to internet functions of autoit, and would like to understand HOW exactly these work and not just to be able to program it in (latter would be usefull also) so your saying hotmail doesnt work with _inetsmtpmail() but GMAIL does? thats very inconveinient.... while i was searching google i found a CMD command that sends email, but not every computer has that specific Batch file.

The reason is that hotmail is not allowing you to use their smtp-server from a free acount (I think they allow it from premium accounts but not sure)

PS

so inconclusion when i use _inetsmtpmail() can i send TO a hotmail account or not even use it sending, also would the error '50' be why?

Well I guess this question is moot now :P

EDIT

alright ive tried my Gmail account and uhhh i still get ERROR = 50.. about 20-30 seconds after i try and send. what am i missing?

According to helpfile it means "Cannot send body". Please make a small reproducer that shows your problem.

By the way, Why doesn't you just use Windows Live Mail? It would be alot easier than writing your own client.

Share this post


Link to post
Share on other sites
CodyBarrett

im writing my own because on dialup it takes 5-10 mins to LOAD live then you have to load the MAIL site...ect... why would it be @error=50... im sending a blank string...

Share this post


Link to post
Share on other sites
AdmiralAlkex

im writing my own because on dialup it takes 5-10 mins to LOAD live then you have to load the MAIL site...ect... why would it be @error=50... im sending a blank string...

Windows Live Mail is not a site, it is a fullblown email application. It has the looks of all the other Live-apps, but has functionality similar to Outlook (but for home users, so you have Live instead of Exchange for contacts, calender and all that stuff).

I use it myself and it's totally awesome, only problem is that my harddrive doesn't like the load when I try to load a few thousand messages at the same time :P (which is every time I start it since I don't clean my inbox very often)

Share this post


Link to post
Share on other sites
CodyBarrett

lol hmmm Thats why IF it supports it, auto delete after 5 days or so....:P... and i dont know, i would just like to make my own lol... so, back to the @error 50, if its a blank string, why would it set that error

Edited by CodyBarrett

Share this post


Link to post
Share on other sites
AdmiralAlkex

lol hmmm Thats why IF it supports it, auto delete after 5 days or so....:P... and i dont know, i would just like to make my own lol... so, back to the @error 50, if its a blank string, why would it set that error

Maybe it doesn't like blank strings? Did you try writing some gibberish or whatever in it?

Share this post


Link to post
Share on other sites
Richard Robertson

Email can be sent with a blank body.

Share this post


Link to post
Share on other sites
AdmiralAlkex

Email can be sent with a blank body.

Then I don't know what can be wrong, do you? I think now would be a good time someone *wink wink* to post a reproducer :P since the rest of us can use Gmail's smtpserver

Share this post


Link to post
Share on other sites
CodyBarrett

well that code at the top, does the exact @error message everytime....i could check the GUictrlread()'s.... idk

Share this post


Link to post
Share on other sites
SpookMeister

I got that error until I tried this solution:

#629901


[u]Helpful tips:[/u]If you want better answers to your questions, take the time to reproduce your issue in a small "stand alone" example script whenever possible. Also, make sure you tell us 1) what you tried, 2) what you expected to happen, and 3) what happened instead.[u]Useful links:[/u]BrettF's update to LxP's "How to AutoIt" pdfValuater's Autoit 1-2-3 Download page for the latest versions of Autoit and SciTE[quote]<glyph> For example - if you came in here asking "how do I use a jackhammer" we might ask "why do you need to use a jackhammer"<glyph> If the answer to the latter question is "to knock my grandmother's head off to let out the evil spirits that gave her cancer", then maybe the problem is actually unrelated to jackhammers[/quote]

Share this post


Link to post
Share on other sites
CodyBarrett

well.. adding -1 to the end does nothing.... niether does having '' as the $s_helo... -1 as the $s_helo does the EXACT same thing.... this is wierd, my Gmail doesnt work, Hotmail doesnt work.

Share this post


Link to post
Share on other sites
AdmiralAlkex

well.. adding -1 to the end does nothing.... niether does having '' as the $s_helo... -1 as the $s_helo does the EXACT same thing.... this is wierd, my Gmail doesnt work, Hotmail doesnt work.

You aren't using Gmail with _INetSmtpMail() are you? Gmail requires ssl which it doesn't have. Try _INetSmtpMailCom()

I use this code to send from my Gmail to my Hotmail and it take like 0,5 secs until I receive it.

(I wrote this for about 2 years ago so it isn't the latest version, but you should be able to fix "importance" yourself)

$s_SmtpServer = "smtp.gmail.com"
$s_FromName = "Gubben i månlådan"
$s_FromAddress = "***@gmail.com"
$s_ToAddress = "***@hotmail.com"
$s_Subject = "zodiäcf"
$as_Body = "hejblaabc123"
$s_AttachFiles = ""
$s_CcAddress = ""
$s_BccAddress = ""
$s_Username = "***@gmail.com"
$s_Password = "***"
$IPPort=465
$ssl=1

$rc = _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject, $as_Body, $s_AttachFiles, $s_CcAddress, $s_BccAddress, $s_Username, $s_Password, $IPPort, $ssl)
MsgBox(0, "Return is " & $rc, "Error is " & @error)

Share this post


Link to post
Share on other sites
CodyBarrett

Well i found a list on Google that shows all the smtp servers, most of them the free ones anyway,NOT HOTMAIL its not free(live)

here

FREE SMTP LIST

Share this post


Link to post
Share on other sites
CodyBarrett

oops i accidently replied instead of EDIT...

ok...

uhh

i mas messing around with the cmd p....... and MAPISEND is almost exactly the same as _Inetmail() am i right? it opens the default mail client and sends the message(except it doesnt send through hotmail) i havennt tried outlook (am testing right now)

EDIT

alright i tested outlook.... they are exactly the same, except for _inetmail you do NOT need to install a batch file. :P i love autoit

Edited by CodyBarrett

Share this post


Link to post
Share on other sites
theAutoitSpammer

can somebody PLEASE post which email service(s) works with this function?

and with which settings?

I been reading this treads and trying different settings and got no were

I'm getting errors 50 and 51 with smpt.att.yahoo.com

thanks in advance

Al :P

Share this post


Link to post
Share on other sites
CodyBarrett

well.... why dont you just use _inetmail() and hide the windows that pop up? i gave up on _Inetsmtpmail() and this is what im using now :P

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.