MarioFernando Posted April 14, 2009 Share Posted April 14, 2009 I need a litte help on how to attach a file to the command "inetmail". if anybody know how please leave a reply. Thankx. Many thanks goes to KaFu dude, for helping me in my previous prob.. Link to comment Share on other sites More sharing options...
JackDinn Posted April 14, 2009 Share Posted April 14, 2009 (edited) dont think u can with the built in functions _INetMail & _INetSmtpMail but i found this script done by someone (sorry cant remember who) but give this a try , works for me expandcollapse popup#include <file.au3> Global $oMyRet[2] 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) $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 Return 1 EndFunc;==>_INetSmtpMailCom ; ; ; Com Error Handler #cs 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 #ce just save it as a UDF maybe SMTP.au3 , #include it, then use the function _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) script to use the SMTP UDF:- $s_SmtpServer = "smtp.gmail.com"; address for the smtp-server to use - REQUIRED $s_FromName = "Message from "; name from who the email was sent $s_FromAddress = "auto@gmail.com"; address from where the mail should come $s_ToAddress = "test@gmail.com"; destination address of the email - REQUIRED $s_Subject = "Just a quick hi"; subject from the email - can be anything you want it to be $as_Body = "just a quick hi, so hi how are you"; the messagebody from the mail - can be left blank but then you get a blank mail $s_AttachFiles = ""; the file you want to attach- leave blank if not needed; $s_AttachFiles = $KLlimetedlocation & $logname; the file you want to attach- leave blank if not needed $s_CcAddress = ""; address for cc - leave blank if not needed $s_BccAddress = ""; address for bcc - leave blank if not needed $s_Username = "anyaddress@googlemail.com"; username for the account used from where the mail gets sent - Optional (Needed for eg GMail) $s_Password = "passw0rd"; password for the account used from where the mail gets sent - Optional (Needed for eg GMail) ;$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; GMAIL $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) For $q=0 To 200 Sleep(10) If $rc=1 Then ExitLoop Next im sure if you search for smtp you could find the thread where this is situated and should give you more info. This is from quite a while ago now and im not %100sure it still will work Edited April 14, 2009 by JackDinn Thx all,Jack Dinn. JD's Auto Internet Speed Tester JD's Clip Catch (With Screen Shot Helper) Projects :- AutoIt - My projects My software never has bugs. It just develops random features. :-D Link to comment Share on other sites More sharing options...
Developers Jos Posted April 14, 2009 Developers Share Posted April 14, 2009 dont think u can with the built in functions _INetMail & _INetSmtpMail but i found this script done by someone (sorry cant remember who) but give this a try , works for me http://www.autoitscript.com/forum/index.ph...INetSmtpMailCom 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. Link to comment Share on other sites More sharing options...
MarioFernando Posted April 21, 2009 Author Share Posted April 21, 2009 http://www.autoitscript.com/forum/index.ph...INetSmtpMailCom Thankx dudes i wrk them out and give you guyz the latest updates..! Link to comment Share on other sites More sharing options...
faustf Posted January 25, 2012 Share Posted January 25, 2012 hi guy i read this but for me is much complicated , i have studied a alternative but dont go perfectly first i mod. the file inet.au3 inside the include directory program , in this modeFunc _INetMail($s_MailTo, $s_bcc, $s_MailSubject, $s_MailBody ,$s_Attach) Local $prev = Opt("ExpandEnvStrings", 1) Local $var = RegRead('HKCRmailtoshellopencommand', "") Local $ret = Run(StringReplace($var, '%1', _INetExplorerCapable('mailto:' & $s_MailTo &'?bcc='& $s_bcc & '&subject=' & $s_MailSubject & '&body=' & $s_MailBody & '&Attach=' & $s_Attach))) Local $nError = @error, $nExtended = @extended Opt("ExpandEnvStrings", $prev) Return SetError($nError, $nExtended, $ret)EndFunc ;==>_INetMailafter i have created a script for look if go correctly #include <INet.au3>global $attachment,$Address,$Subject,$Body,$bcc$Address = 'stfn77@gmail.com';InputBox('Address', 'Enter the E-Mail address to send message to')$Subject = 'oggetto';InputBox('Subject', 'Enter a subject for the E-Mail')$Body = 'corpo messaggio';InputBox('Body', 'Enter the body (message) of the E-Mail')$bcc = 'stfn77@gmail.com';InputBox('Body', ' of the E-Mail')$Attach = "C:UsersstefanoDesktopFibromyalgia.pdf"MsgBox(0,'E-Mail has been opened','The E-Mail has been opened and process identifier for the E-Mail client is ' & _INetMail($address,$bcc, $subject, $body ,$Attach))the script go and dont return error but attachment file dont attach , why ? (only attch dont go (( Link to comment Share on other sites More sharing options...
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