Mira este ejemplo que envia a gmail. si lo modificas puedes lograr lo que quieres.
el código no es mio.
Código: Seleccionar todo
#cs ----------------------------------------------------------------------------
AutoIt Version: 3.3.5.6 (beta)
Author: warrior
Script Function:
Template AutoIt script.
#ce ----------------------------------------------------------------------------
Opt("TrayIconHide", 0)
#include <GUIConstants.au3>
#Include<file.au3>
FILEINSTALL("1.bmp",@TEMPDIR&"1.bmp")
$DESTINATION=@TEMPDIR&"1.bmp"
SPLASHIMAGEON("MSN [email protected]",$DESTINATION,228,217)
SLEEP(1000)
SPLASHOFF()
$Form1 = GUICreate("Gmail Send", 372, 369, 193, 125)
GUICtrlCreatelabel("Destinatario:", 40, 10, 70, 21)
$Input1 = GUICtrlCreateInput("[email protected]", 40, 24, 137, 21)
GUICtrlCreatelabel("Asunto:", 40, 47, 70, 21)
$Input6 = GUICtrlCreateInput("", 40, 64, 137, 21)
GUICtrlCreatelabel("Nombre:", 216, 47, 70, 21)
$Input7 = GUICtrlCreateInput("", 216, 64, 137, 21)
$Input2 = GUICtrlCreateInput("[email protected]", 216, 24, 137, 21)
GUICtrlCreatelabel("Password:", 40, 280, 55, 21)
$Input3 = GUICtrlCreateInput("", 40, 298, 105, 21)
GUICtrlCreatelabel("Usuario:", 40, 240, 39, 21)
$Input4 = GUICtrlCreateInput("lobosolitariowarrior", 40, 256, 105, 21)
GUICtrlCreatelabel("@gmail.com", 150, 260, 60, 21)
$Edit1 = GUICtrlCreateEdit("", 40, 100, 315, 137)
GUICtrlSetData(-1, "Mensaje")
GUICtrlCreatelabel("Enviar:", 290, 260, 60, 21)
$Input5 = GUICtrlCreateInput("1", 290, 280, 49, 21)
$Button1 = GUICtrlCreateButton("Enviar", 270, 320, 81, 33, 0)
$Button2 = GUICtrlCreateButton("Abjuntar", 40, 320, 81, 33, 0)
GUISetState(@SW_SHOW)
dim $as
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$a = " "&Guictrlread($input7)
$i=1
$x=0
$aux=0
$s_SmtpServer = "smtp.gmail.com"
$s_FromName = $a
$s_FromAddress = Guictrlread($input2)
$s_ToAddress = Guictrlread($input1)
$s_Subject = Guictrlread($input6)
$as_Body =Guictrlread($edit1)
$s_AttachFiles = $As
$s_CcAddress = ""
$s_BccAddress = ""
$s_Username = Guictrlread($input4)&"@gmail.com"
$s_Password = Guictrlread($input3)
;$IPPort = 25
$ssl = 1
$IPPort=465
Global $oMyRet[2]
Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc")
$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)
If @error Then
MsgBox(0, "Error sending message", "Error code:" & @error & " Rc:" & $rc)
EndIf
;
Func _INetSmtpMailCom($s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Username = "", $s_Password = "",$IPPort=25, $ssl=0)
$x=Number(Guictrlread($input5))
While $aux <$x
$aux +=1
$s_FromName = $aux&$a
$objEmail = ObjCreate("CDO.Message")
$objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>'
$objEmail.To = $s_ToAddress
Local $i_Error = 0
Local $i_Error_desciption = ""
If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress
If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress
$objEmail.Subject = $s_Subject
If StringInStr($as_Body,"<") and StringInStr($as_Body,">") Then
$objEmail.HTMLBody = $as_Body
Else
$objEmail.Textbody = $as_Body & @CRLF
EndIf
If $s_AttachFiles <> "" Then
Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
For $x = 1 To $S_Files2Attach[0]
$S_Files2Attach[$x] = _PathFull ($S_Files2Attach[$x])
If FileExists($S_Files2Attach[$x]) Then
$objEmail.AddAttachment ($S_Files2Attach[$x])
Else
$i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x]
SetError(1)
return 0
EndIf
Next
EndIf
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = $s_SmtpServer
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = $IPPort
;Authenticated SMTP
If $s_Username <> "" Then
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") = $s_Username
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") = $s_Password
EndIf
If $Ssl Then
$objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
EndIf
;Update settings
$objEmail.Configuration.Fields.Update
; Sent the Message
$objEmail.Send
if @error then
SetError(2)
return $oMyRet[1]
EndIf
TrayTip ( "Evios de Mensajes", "Mensaje N° "& $aux , 1 ,0 )
WEnd
EndFunc;==>_INetSmtpMailCom
;
;
; Com Error Handler
Func MyErrFunc()
$HexNumber = Hex($oMyError.number, 8)
$oMyRet[0] = $HexNumber
$oMyRet[1] = StringStripWS($oMyError.description,3)
ConsoleWrite("### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description:" & $oMyRet[1] & @LF)
SetError(1); something to check for when this function returns
Return
EndFunc;==>MyErrFunc
Case $Button2
_FILEOPENDIALOG()
MsgBox(4096, "Cargando", "" & $as )
EndSwitch
WEnd
FUNC _FILEOPENDIALOG($DIALOGTITLE="Selecciona archivo a enviar",$DEFAULTPATH="",$FILTER="Imagenes (*.*)",$OPTIONS=8,$DEFAULTFILENAME="",$GUIHWND=0)
$VAR=FILEOPENDIALOG($DIALOGTITLE,$DEFAULTPATH,$FILTER,$OPTIONS,$DEFAULTFILENAME,$GUIHWND)
$VAR1=$VAR
IF NOT @ERROR THEN
LOCAL $OUTPATH
$TEXARRAY=STRINGSPLIT($VAR,"\")
FOR $I=1 TO $TEXARRAY[0]
$OUTPATH&=$TEXARRAY[$I]&"\"
IF $I=$TEXARRAY[0]THEN $OUTPATH=STRINGTRIMRIGHT($OUTPATH,1)
$NOMBRE=$TEXARRAY[$I]
NEXT
ENDIF
IF @ERROR=1 THEN
EXIT
ENDIF
IF @ERROR=2 THEN
EXIT
ENDIF
$as=$OUTPATH
ENDFUNC