Jump to content

Recommended Posts

  • Developers
Posted

I looked at your first post, but I don't see an example.

The shown AutoIt3 code is an example that will work when you use a valid Email account with the proper providers information.

For GMail make sure you set the SSL and PORT correctly as indicated in the Code.

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.
  :)

Posted

I want seperate the code into a seperate .au3 file and call the function from another .au3 file. But it don't work. What do I have to put into the seperate .au3 file and what in the calling file?

  • 2 weeks later...
Posted

Hi,

Has anyone used this with a compressed (ZIP) file as an attachment.

I've been trying without any success. My email client (Lotus Notes) receives the email but cannot open it. Instead it shows the error "File cannot be created". I've also tried to my ISP account, and the email never arrives.

However, this is ONLY when adding an ZIP file (or a ZIP file that has been renamed). If I just attach a text file (for example) then everything works fine.

Thanks

Iain.

Posted

Hi,

Has anyone used this with a compressed (ZIP) file as an attachment.

I've been trying without any success. My email client (Lotus Notes) receives the email but cannot open it. Instead it shows the error "File cannot be created". I've also tried to my ISP account, and the email never arrives.

However, this is ONLY when adding an ZIP file (or a ZIP file that has been renamed). If I just attach a text file (for example) then everything works fine.

Thanks

Iain.

Ignore me please. I'd done something fairly silly which was causing my issues.

Thanks

Iain

  • 1 month later...
Posted

Is there a reason I can't find an helo in this UDF?

How would I include one?

I can get it to work through gmail but not a local smtp provider that seems to require helo.

Awesome UDF by the way.

TIA,

Posted

I think I've answered this now, but correct me if I'm wrong.

Seeing this UDF makes sure I authenticate with username and password I have been able to log in to an upstream smtp server without needing helo.

I'm guessing this is how it is meant to work??

If I'm wrong please tell me as I'd love to know.

Anyhow - I've now got a working script now that sends mail (effectively) via my local smtp server without helo.

Once again - great UDF

  • 2 weeks later...
Posted (edited)

I reviewed this thread twice and almost missed the 1 post explaining how to do multiple attachments. Which was luck, because the post had nothing to do with multiple attachments, it was just a usage example on one of the later pages. So I figured I would throw this out there for the searchers. :idea:

In order to send more than one attachment, the $attachment line should look like this...

$AttachFiles = $File1 & ";" & $File2 & ";" & $File3

or

$AttachFiles = "C:\test1.jpg;C:\test2.jpg;C:\test3.jpg"

Simply separate the attachments with ;

Edited by BinaryBrother

SIGNATURE_0X800007D NOT FOUND

  • 2 weeks later...
Posted (edited)

Works Great for me after a few hours of testing with Gmail, wasn't working and I was getting the error :

Error Code:2 Description: The transport failed to connect to the server.

Tried lots of things and finally got it working on my own. (I read this whole topic, but none of the solutions were working)

So here's how I got it working, might sound silly, but worked for me...

I saved the UDF section (including the Com handler to it's own au3 file. Then created a dummy file in which I put :

#include "smtp.au3"
;##################################
; Variables
;##################################
$SmtpServer = "smtp.gmail.com"          ; address for the smtp-server to use - REQUIRED
$FromName = "Name"                      ; name from who the email was sent
$FromAddress = "name@gmail.com" ; address from where the mail should come
$ToAddress = "name@gmail.com"  ; destination address of the email - REQUIRED
$Subject = "Test2"                   ; subject from the email - can be anything you want it to be
$Body = "TEXT2 <b>BOLD</b>"                ; the messagebody from the mail - can be left blank but then you get a blank mail
$Importance = "Normal"                  ; Send message priority: "High", "Normal", "Low"
$Username = "name"    ; username for the account used from where the mail gets sent - REQUIRED
$Password = "password"                  ; password for the account used from where the mail gets sent - REQUIRED
$IPPort = 465                            ; port used for sending the mail
$ssl = 1                               ; enables/disables secure socket layer sending - put to 1 if using httpS

Notice I removed the AttachFiles,CcAddress and BccAddress.

<EDIT>

Also notice that for authentication, Gmail accepts both "name" and "name@gmail.com".

for people asking (maybe add this to the first post), the FromName will show up when you send an e-mail, but this is just the name, if you look at the header of the e-mail correctly, you'll see something like "Name LastName <Name.LastName@gmail.com>". your e-mail client decides which one it shows you...

</EDIT>

Then when calling the function, I simply replaced the 3 variables with empty quotes like this :

_INetSmtpMailCom($SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, "", "", "", $Importance, $Username, $Password, $IPPort, $ssl)

Has since worked great, I don't know why, I tried putting the variables back after and it still worked fine, I'm guessing there was some type of hidden character playing against me within one of those variables, so if you have any problem, at least give it a try.

z3r0c00l12

Edited by z3r0c00l12
Posted (edited)

Little touch up required in the Attach files part of the udf,

Can you add support for full path as the attach file variable, so that if I input "C:\script\output.txt" it doesnt give an error an stop the script, instead, have the script check if the path is full, if it is, send as is, if the path is relative, then use the _PathFull function.

Here is what I did to solve my problem, maybe you could use that, or optimize it :

if Stringmid($S_Files2Attach[$x],2, 1) = ":" then

Else
$S_Files2Attach[$x] = _PathFull($S_Files2Attach[$x])
EndIf

Also, I noticed while looking at the debug output that the file attach debug will show this (for each file sent):

@@ Debug(62) : $S_Files2Attach = 
>Error code: 0

Looking at the code I found that the consolewrite was not using the array properly, this is why no filename is shown in the debug output.

ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF) ;### Debug Console

should be changed to :

ConsoleWrite('@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach[$x] & @LF & '>Error code: ' & @error & @LF) ;### Debug Console

Thank you,

z3r0c00l12

Edited by z3r0c00l12
  • Developers
Posted

I do not understand what the issue is when the fullpath is already defined as that should be supported too by _PathFull().

What is exactly going wrong for you?

I fixed the debug line which actually shouldn't have been there any more and was a leftover from some testing.

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.
  :)

Posted

I was getting an error from the pathfull function when giving it a full path, I don't know what I did, but it's working normally now, using a full path. since I can't reproduce the error anymore and I'm using your script the way it was initially, I'll say it was a mistake on my part somewhere. I removed the debug line, like you said.

My next step is trying to get my Cisco routers and switches to send syslogs (receive them with autoit), then have autoit send me the logs by email every day.

Thanks again for a great script.

z3r0c00l12

  • 2 weeks later...
Posted

What's the use of $s_FromAddress ?

When I send an e-mail, it will say the $Username as the "from address"

And I can't make it work for Hotmail, only works with Gmail

  • Developers
Posted

What is the return value of the function _INetSmtpMailCom? @error=1 if an error occurs and @error=0 if there is no error?

Look at the bottom of the example in the first post. The @error is set to 2 and the return vealu to the Description of the error from the CommError func,

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.
  :)

  • Developers
Posted (edited)

What's the use of $s_FromAddress ?

:idea: the Email address you send the Email for?

And I can't make it work for Hotmail, only works with Gmail

This needs an SMTP Server either secure or Open. Believe Hotmail only has this available for paid accounts.

Jos

Edited 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.
  :)

Posted

Hey guys!

I'm not good at searching topics and posts.

When I tried to add an attachment using the script, I get this....

+> File attachment added: C:\Users\Gavin\Documents\AutoItImage.jpg

F:\AutoIt\ResearchDATA\SMTP_JOS\RC001.au3 (259) : ==> Object referenced outside a "With" statement.:

.AddAttachment($S_Files2Attach[$x])

^ ERROR

->16:31:09 AutoIT3.exe ended.rc:1

Any ideas?

Regards,

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...