resulta que tengo un script para enviar correos electrónico que corre bien y me ha funcionado de maravilla
pero el problema que tengo es que quiero adaptarlo a un programa que estoy haciendo siempre con Autoit...
Código: Seleccionar todo
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
$VentanaAplicacion = GUICreate("Enviar correo...", 450, 420, 200, 125)
$Para = GUICtrlCreateLabel("Para:", 25, 15, 30, 20)
$ParaInput = GUICtrlCreateInput("", 70, 15, 350, 20)
$De = GUICtrlCreateLabel("De:", 25, 40, 20, 20)
$DeInput = GUICtrlCreateInput("", 70, 40, 350, 20)
$Asunto = GUICtrlCreateLabel("Asunto:", 25, 65, 40, 20)
$AsuntoInput = GUICtrlCreateInput("", 70, 65, 350, 20)
$Texto = GUICtrlCreateInput("", 50, 130, 350, 200)
GUICtrlSetData(-1, "")
$Groupo = GUICtrlCreateGroup("Texto a enviar...", 20, 100, 400, 240)
$AcercaDe = GUICtrlCreateLabel("Softcom Systems Incorporated", 120, 370, 200, 35)
$Enviar = GUICtrlCreateButton("Enviar", 25, 360, 65, 35)
GUISetState(@SW_SHOW)
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Enviar
;Declaramos las globales
Global $Server="mail.ivermedia.com"
Global $Name="Melvin"
Global $FromAddress=$DeInput; el correo que lo envia
Global $ToAddress=$ParaInput; correo de a quien envia
Global $CCAddress="";cc"
Global $BCCAddress="";bcc"
Global $Subject=$AsuntoInput; el asunto
Global $Body=$Texto
Global $Attach= ""
Global $Importance="";normal"
Global $User="[email protected]"
Global $Password="cvkjsp0lvk9"
Global $Port=25
Global $Ssl=0
Global $MSend
Global $OMyRet[2]
Global $OMyError=ObjEvent("AutoIt.Error", "MyErrFunc")
$mSend=_INetSmtpMailCom($Server, $Name, $FromAddress, $ToAddress, $Subject, $Body, $Attach, $CCAddress, $BCCAddress, $Importance, $User, $Password, $Port, $Ssl)
;msgbox(0, "Informe", $MSend)
If $mSend = "0" Then
MsgBox(32, "Windows...", "El envió fue realizado exitosamente...", 10)
Else
MsgBox(16, "Windows...", "Ocurrio un error durante el envió...", 10)
EndIf
Exit
Func _INetSmtpMailCom($S_SmtpServer, $S_FromName, $S_FromAddress, $S_ToAddress, $S_Subject="", $As_Body="", $S_AttachFiles="", $S_CcAddress="", $S_BccAddress="", $S_Importance="Normal", $S_Username="", $S_Password="", $IPPort=25, $Ssl=0)
Local $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
SetError(1)
Return "Archivo no encontrado: "&$S_Files2Attach[$X]
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
If Number($IPPort)=0 then $IPPort=25
$ObjEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=$IPPort
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
$ObjEmail.Configuration.Fields.Update
Switch($S_Importance)
Case "High"
$ObjEmail.Fields.Item ("urn:schemas:mailheader:Importance")="High"
Case "Normal"
$ObjEmail.Fields.Item ("urn:schemas:mailheader:Importance")="Normal"
Case "Low"
$ObjEmail.Fields.Item ("urn:schemas:mailheader:Importance")="Low"
EndSwitch
$ObjEmail.Fields.Update
$ObjEmail.Send
If @Error Then
SetError(2)
Return $OMyRet[1]
EndIf
$ObjEmail=""
EndFunc
Func MyErrFunc()
$HexNumber=Hex($OMyError.number, 8)
$OMyRet[0]=$HexNumber
$OMyRet[1]=StringStripWS($OMyError.description, 3)
SetError(1)
Return $OMyRet[1]
EndFunc
Exit
EndSwitch
WEnd