zxc3 Posted May 27, 2010 Posted May 27, 2010 error on this line for me: .AddAttachment($S_Files2Attach[$x])
Developers Jos Posted May 27, 2010 Author Developers Posted May 27, 2010 error on this line for me: .AddAttachment($S_Files2Attach[$x]) Please do not post here if you cannot be bothered to post a well formed problem report with enough detail to be able to help you. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
tnext Posted May 28, 2010 Posted May 28, 2010 (edited) This script works very good but i just cant get the file attachment to work. I get the following error: @@ Debug : $S_Files2Attach[$x] = H:\Bureaublad\GWSend.ini and H:\Bureaublad\mail.au3(77,52) : ERROR: Object method or attribute accessed without 'With' .AddAttachment($S_Files2Attach[$x]) What am i doing wrong? If you need more info then plz tell me expandcollapse popup#Include <file.au3> ;################################## ; INI ;################################## $var1 = IniRead("H:\Bureaublad\config.ini", "config", "SMTP", "") $var2 = IniRead("H:\Bureaublad\config.ini", "opmaak", "NAAM", "") $var3 = IniRead("H:\Bureaublad\config.ini", "config", "VAN-EMAIL", "") $var4 = IniRead("H:\Bureaublad\config.ini", "opmaak", "NAAR-EMAIL", "") $var5 = IniRead("H:\Bureaublad\config.ini", "opmaak", "ONDERWERP", "") $var6 = IniRead("H:\Bureaublad\config.ini", "opmaak", "BODY", "") $var7 = IniRead("H:\Bureaublad\config.ini", "opmaak", "ATTACHMENT", "") $var8 = IniRead("H:\Bureaublad\config.ini", "opmaak", "CC", "") $var9 = IniRead("H:\Bureaublad\config.ini", "opmaak", "BCC", "") $var10 = IniRead("H:\Bureaublad\config.ini", "config", "PRIORITY", "Normal") $var11 = IniRead("H:\Bureaublad\config.ini", "config", "USERNAME", "") $var12 = IniRead("H:\Bureaublad\config.ini", "config", "PASSWORD", "") $var13 = IniRead("H:\Bureaublad\config.ini", "config", "IPPORT", "25") ;################################## ; Variables ;################################## $SmtpServer = $var1 ; address for the smtp-server to use - REQUIRED $FromName = $var2 ; name from who the email was sent $FromAddress = $var3 ; address from where the mail should come $ToAddress = $var4 ; destination address of the email - REQUIRED $Subject = $var5 ; subject from the email - can be anything you want it to be $Body = $var6 ; the messagebody from the mail - can be left blank but then you get a blank mail $AttachFiles = $var7 ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed $CcAddress = $var8 ; address for cc - leave blank if not needed $BccAddress = $var9 ; address for bcc - leave blank if not needed $Importance = $var10 ; Send message priority: "High", "Normal", "Low" $Username = $var11 ; username for the account used from where the mail gets sent - REQUIRED $Password = $var12 ; password for the account used from where the mail gets sent - REQUIRED $IPPort = $var13 ; port used for sending the mail $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS ;################################## ; Script ;################################## Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl) If @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) EndIf ; ; The UDF 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]) ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console If FileExists ($S_Files2Attach[$x]) Then ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF) .AddAttachment($S_Files2Attach[$x]) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) 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 If Number($IPPort) = 0 then $IPPort = 25 $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 ; Set Email Importance 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 ; Sent the Message $objEmail.Send If @error Then SetError(2) Return $oMyRet[1] EndIf $objEmail="" 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 Edited May 28, 2010 by tnext
Developers Jos Posted May 28, 2010 Author Developers Posted May 28, 2010 (edited) Ok.... understand it now Looks like I made a mistake the last time I updated the posted code. updated the first post in the thread and just update your script with this line: $objEmail.AddAttachment($S_Files2Attach[$x]) moet lukken Edited May 28, 2010 by Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
tnext Posted May 28, 2010 Posted May 28, 2010 ahh, could have seen that on my own to be honest maar thanx 4 snelle antwoord - im a newbie
P516988 Posted July 15, 2010 Posted July 15, 2010 expandcollapse popup; ;################################## ; Include ;################################## #Include<file.au3> ;################################## ; Variables ;################################## $SmtpServer = "MailServer" ; address for the smtp-server to use - REQUIRED $FromName = "Name" ; name from who the email was sent $FromAddress = "your@Email.Address.com" ; address from where the mail should come $ToAddress = "your@Email.Address.com" ; destination address of the email - REQUIRED $Subject = "Userinfo" ; subject from the email - can be anything you want it to be $Body = "" ; the messagebody from the mail - can be left blank but then you get a blank mail $AttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed $CcAddress = "CCadress1@test.com" ; address for cc - leave blank if not needed $BccAddress = "BCCadress1@test.com" ; address for bcc - leave blank if not needed $Importance = "Normal" ; Send message priority: "High", "Normal", "Low" $Username = "******" ; username for the account used from where the mail gets sent - REQUIRED $Password = "********" ; password for the account used from where the mail gets sent - REQUIRED $IPPort = 25 ; port used for sending the mail $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS ;~ $IPPort=465 ; GMAIL port used for sending the mail ;~ $ssl=1 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS ;################################## ; Script ;################################## Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl) If @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) EndIf ; ; The UDF 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]) ;~ ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console If FileExists($S_Files2Attach[$x]) Then ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF) $objEmail.AddAttachment($S_Files2Attach[$x]) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) 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 If Number($IPPort) = 0 then $IPPort = 25 $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 ; Set Email Importance 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 ; Sent the Message $objEmail.Send If @error Then SetError(2) Return $oMyRet[1] EndIf $objEmail="" 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 Edit: Fixed Bcc ... Edit: Added support for different port and SLL which are used by GMail (Port 465) Edit: Added Importance support (10/2008)
Developers Jos Posted July 15, 2010 Author Developers Posted July 15, 2010 Is there a question in that last post? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
P516988 Posted July 15, 2010 Posted July 15, 2010 -Nice job, I test it with a gmail account and work fine. -I added notification to the user if the email was sent. If @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) Else MsgBox(0, "Message sent without error.", "Error code:" & @error & " Description:" & $rc) EndIf Thanks a lot for this excellent UDF.
ijourneaux Posted July 20, 2010 Posted July 20, 2010 I have been using INetSmtpMailCOm successfully for a while but today, I bumped into an interesting problem. This is the typical call $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl) All of the paramaters are read in from an ini file. The key parameter is this case is $ssl. It is configured to be 0 in the ini file and I have confirmed that it is 0 prior to the call to _INetSmtpMailCom. Unfortunately when _INetSmtpMailCom is executed executed, it returns a COM error indicating that it can't connect to the SMTP server. If I make a single change and manually set $ssl=0 immediately prior to the call, _INetSmtpMailCom works as it should. What is different between setting $ssl to 0 explicitly to 0 and reading a 0 value from the ini file? When I get to my development machine, I will post a sample code that illustrates the error. Take Care
ijourneaux Posted July 20, 2010 Posted July 20, 2010 Here is a code based on the INetSmtpMailCom sample. expandcollapse popup; ;################################## ; Include ;################################## #include <INetSmtpMailCom.au3> #include <file.au3> ;################################## ; Variables ;################################## ;################################## ; Variables ;################################## Global $SMTPServer Global $FromName Global $FromAddress Global $ToAddress Global $SMTPServer Global $Subject Global $Body Global $AttachFiles Global $CCAddress Global $BccAddress Global $Importance Global $Username Global $Password Global $IPPort Global $ssl ;################################## ; Script ;################################## readini() ; This call fails $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject & "Before" , $Body, "", $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl) ; This one works $ssl = 0 $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject & "After" , $Body, "", $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl) Func ReadIni() $SMTPServer = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "SMTPServer", "NotFound") $FromName = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "FromName", "NotFound") $FromAddress = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "FromAddress", "NotFound") $ToAddress = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "ToAddress", "NotFound") $Subject = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "Subject", "NotFound") $Body = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "Body", "NotFound") $CCAddress = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "CCAddress", "NotFound") $BccAddress = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "BccAddress", "NotFound") $Importance = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "Importance", "NotFound") $Username = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "Username", "NotFound") $Password = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "Password", "NotFound") $IPPort = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "IPPort", "NotFound") $ssl = IniRead(@scriptdir & "\IFMAutoReports.ini", "IFMAutoReports3D-PM16", "ssl", "NotFound") EndFunc Here is the ini file. [IFMAutoReports3D-PM16] SmtpServer = "relay.servername.net" FromName = "From" FromAddress = "from@address.com" ToAddress = "to@address.com" Subject = "Subject" Body = "The PDF file in this email is located in folder: " CcAddress = "cc@address.com" BccAddress = "" Importance = "Normal" Username = "" Password = "" IPPort=25 ssl=0
Developers Jos Posted July 21, 2010 Author Developers Posted July 21, 2010 reading INI file keywords return a STRING not a Number which could give issues. Try using Number() on the retrieved string from the INI file. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
ijourneaux Posted July 21, 2010 Posted July 21, 2010 Thanks for the reply. I thought of that as a possibility but I assumed that Autoit variables didn't have to be type cast. If this is required should the change be in INetSmtpMailCom (this would seem to be the correct place) or is the script calling INetSmtpMailCom?
ijourneaux Posted July 23, 2010 Posted July 23, 2010 Thanks for the reply. I thought of that as a possibility but I assumed that Autoit variables didn't have to be type cast. If this is required should the change be in INetSmtpMailCom (this would seem to be the correct place) or is the script calling INetSmtpMailCom? I would recommend that the following change be made to INetSmtpMailCom From If $ssl Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf To If $ssl = 1 Then $objEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True EndIf This will allow the code to work regardless of the how $ssl is sourced. Everything works fine if $ssl is defined as $ssl=1 or $ssl=0 prior to calling INetSmtpMail but doesn't work when $ssl is read in from an ini file. Take Care
LeHuynhNam Posted August 3, 2010 Posted August 3, 2010 (edited) helloi'm using AutoIT ver 3.3.0.0 and i got this error@@ Debug(62) : $S_Files2Attach = >Error code: 0how can i fix itthanks in advancedps: i use for Gmail acc Edited August 3, 2010 by LeHuynhNam
Developers Jos Posted August 3, 2010 Author Developers Posted August 3, 2010 Tried the last version of this UDF from the first post? SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
LeHuynhNam Posted August 4, 2010 Posted August 4, 2010 yes of course, i can send an email with attached file but still have this error (test on Yahoo mail)
Developers Jos Posted August 4, 2010 Author Developers Posted August 4, 2010 yes of course, i can send an email with attached file but still have this error (test on Yahoo mail) Doubt that since it was change a while ago to comment out this particular line! This is the section from the code shown in the first post that contanins the commented line you refer too. If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit($s_AttachFiles, ";") For $x = 1 To $S_Files2Attach[0] $S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x]) ;~ ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console If FileExists($S_Files2Attach[$x]) Then ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF) $objEmail.AddAttachment($S_Files2Attach[$x]) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) SetError(1) Return 0 EndIf Next EndIf SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
LeHuynhNam Posted August 5, 2010 Posted August 5, 2010 oh thank you, sory for my mistake, i think it was an error
adik2dmax666 Posted September 3, 2010 Posted September 3, 2010 (edited) I get this error: ### COM Error ! Number: 800401F3 ScriptLine: 36 Description: ### COM Error ! Number: 000000A9 ScriptLine: 37 Description: ### COM Error ! Number: 000000A9 ScriptLine: 38 Description: ### COM Error ! Number: 000000A9 ScriptLine: 43 Description: ### COM Error ! Number: 000000A9 ScriptLine: 47 Description: ### COM Error ! Number: 000000A9 ScriptLine: 64 Description: ### COM Error ! Number: 000000A9 ScriptLine: 65 Description: ### COM Error ! Number: 000000A9 ScriptLine: 67 Description: ### COM Error ! Number: 000000A9 ScriptLine: 70 Description: ### COM Error ! Number: 000000A9 ScriptLine: 71 Description: ### COM Error ! Number: 000000A9 ScriptLine: 72 Description: ### COM Error ! Number: 000000A9 ScriptLine: 75 Description: ### COM Error ! Number: 000000A9 ScriptLine: 78 Description: ### COM Error ! Number: 000000A9 ScriptLine: 84 Description: ### COM Error ! Number: 000000A9 ScriptLine: 88 Description: ### COM Error ! Number: 000000A9 ScriptLine: 90 Description: This is my script. expandcollapse popup#include <file.au3> Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error", "MyErrFunc") ;################################## ; Variables ;################################## $SmtpServer = "smtp.gmail.com" ; address for the smtp-server to use - REQUIRED $FromName = "Ground Defiance" ; name from who the email was sent $FromAddress = "testmail@gmail.com" ; address from where the mail should come $ToAddress = "testmail@gmail.com" ; destination address of the email - REQUIRED $Subject = "Test Mail" ; subject from the email - can be anything you want it to be $Body = "" ; the messagebody from the mail - can be left blank but then you get a blank mail $AttachFiles = "" ; the file(s) you want to attach seperated with a ; (Semicolon) - leave blank if not needed $CcAddress = "" ; address for cc - leave blank if not needed $BccAddress = "" ; address for bcc - leave blank if not needed $Importance = "Normal" ; Send message priority: "High", "Normal", "Low" $Username = "testmail@gmail.com" ; username for the account used from where the mail gets sent - REQUIRED $Password = "*********" ; password for the account used from where the mail gets sent - REQUIRED ;~ $IPPort = 25 ; port used for sending the mail ;~ $ssl = 0 ; enables/disables secure socket layer sending - put to 1 if using httpS $IPPort=465 ; GMAIL port used for sending the mail $ssl=1 ; GMAILenables/disables secure socket layer sending - put to 1 if using httpS $rc = _INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl) If @error Then MsgBox(0, "Error sending message", "Error code:" & @error & " Description:" & $rc) EndIf 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]) ;~ ConsoleWrite('@@ Debug : $S_Files2Attach[$x] = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console If FileExists($S_Files2Attach[$x]) Then ConsoleWrite('+> File attachment added: ' & $S_Files2Attach[$x] & @LF) $objEmail.AddAttachment($S_Files2Attach[$x]) Else ConsoleWrite('!> File not found to attach: ' & $S_Files2Attach[$x] & @LF) 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 If Number($IPPort) = 0 then $IPPort = 25 $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 ; Set Email Importance 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 ; Sent the Message $objEmail.Send If @error Then SetError(2) Return $oMyRet[1] EndIf $objEmail="" 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 Autoit Version: Latest Tried solutions: regsvr32 cdo.dll , same errors regsvr32 cdosys.dll , same errors Edited September 5, 2010 by adik2dmax666 First learn computer science and all the theory. Next develop a programming style. Then forget all that and just hack. -George Carrette[sub]GD Keylogger Creator (never released)[/sub][sub]Garena Autojoin v3.0[/sub]
chadskinner Posted September 21, 2010 Posted September 21, 2010 How about using with a Proxy. I've dinked around but can't seem to get it to work with a proxy. Tried setting proxy in script as well as env variables.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now