Jump to content
Sign in to follow this  
myspacee

Send mail with attachment

Recommended Posts

myspacee

Hello,

read on forum several send mail example. Few about send mail + attachment

I want to include this feature in one of my script, but not find an UDF or simple example. (some required external resource [gmail, etc])

Post here a vbs script that done this task in simple way :

'_________________________________________________________________
'      set vars
'_________________________________________________________________
dim Attachment
set vArgs = WScript.Arguments
Attachment = "c:\tmuninst.ini"
Set objFSO = CreateObject("Scripting.FileSystemObject")


'_________________________________________________________________
'       set MAIL
'_________________________________________________________________
Set objMessage = CreateObject("CDO.Message") 
objMessage.Subject = "this is Subject  " & date & " " & TIME
objMessage.From = "mike@autoit.it" 
objMessage.To = "robert@autoit.it" 
objMessage.TextBody = "send report"


'_________________________________________________________________
'   In attachment exist send 
'_________________________________________________________________
If objFSO.FileExists(Attachment) Then
    objMessage.AddAttachment Attachment
Else
    objMessage.Subject = date & " " & TIME & ". Report NOt exists. "
End If


'_________________________________________________________________
'       SERVER SMTP
'_________________________________________________________________

objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 

'NOME O IP SERVER CON SMTP ATTIVO
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "yyy.xxx.1.36"

'PORTA DEL SERVER (SMTP ASCOLTA SULLA 25)
objMessage.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 

objMessage.Configuration.Fields.Update


'_________________________________________________________________
'       SEND
'_________________________________________________________________
objMessage.Send

I've an SMTP mail server on my lan so i want to use it (not want to use external resource [gmail, yahoo, etc])

Anyone can suggest me something easy to include this in a script ?

Thank you for reading,

m.

Share this post


Link to post
Share on other sites
Juvigy

Do you have outlook (but not exkspress)?

$oOApp = ObjCreate("Outlook.Application")

$oOMail = $oOApp.CreateItem($olMailItem)

$oOMail.Save

With $oOMail

.To = (" type@here.com")

.Subject = "test mail"

.BodyFormat = 3

.Importance = 1

.Body = "Hi there"

.attachments.add ("full file path")

.Display

.Send

EndWith

Share this post


Link to post
Share on other sites
myspacee

thank you for reply,

Need this feature for a script that do something on a server as scheduled script.

Then it send result to different users. I can't use outlook.

m.

Share this post


Link to post
Share on other sites
myspacee

up request,

thank you,

m.

Share this post


Link to post
Share on other sites
myspacee

thank you for reply,

but understand that UDF needs external SMTP server with username password. (eg Gmail)

my script must run in work intranet with no internet access, but internal mail server (that support send trought SMTP)

You know if is possible use also LAN resources ?

m.

Share this post


Link to post
Share on other sites
Juvigy

Isnt it possible to install Outlook on the server?

Share this post


Link to post
Share on other sites
water

Or you could use an external program like blat (Blat is a Win32 command line utility that sends eMail using SMTP).

No need for installation (but you can), all necessary information can be provided on the command line.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Share this post


Link to post
Share on other sites
myspacee

Thank again for interest.

At this point use my .vbs script and integrate it in AI script.

m.

Share this post


Link to post
Share on other sites
Juvigy

If it is only that i think there is VBS to AUtoit converter available in the forum.Use the search.

Share this post


Link to post
Share on other sites
Zedna

thank you for reply,

but understand that UDF needs external SMTP server with username password. (eg Gmail)

my script must run in work intranet with no internet access, but internal mail server (that support send trought SMTP)

You know if is possible use also LAN resources ?

m.

I think this UDF will work in this scenario. Just try it...

Maybe there must be set some parametres for connection.

Share this post


Link to post
Share on other sites
LurchMan

I've implemented a simliar script on a couple servers where I work and if you have a mail server just use that as the smtp server and youll be able to send internal emails only, and if you want to send external emails then youll have to use username / password.


Dating a girl is just like writing software. Everything's going to work just fine in the testing lab (dating), but as soon as you have contract with a customer (marriage), then your program (life) is going to be facing new situations you never expected. You'll be forced to patch the code (admit you're wrong) and then the code (wife) will just end up all bloated and unmaintainable in the end.

Share this post


Link to post
Share on other sites
99ojo

Hi,

i'm using _INetSmtpMail function with an internal LotusNotes SMTP Server.

You don't need user and password verifaction, if your smtp sever is configured to use it without user verification.

In our case, the LoNo SMTP does only IP Filtering on SMTP Port.

Depending on your SMTP server you may define $s_helo = "" and $s_first = -1 (see help file _INetSmtpMail function)

Good luck

;-))

Stefan

Edited by 99ojo

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×