using System;
using Ventuz.Kernel;
using System.Net;
using System.Net.Mail;
using System.Web;
public class Script : ScriptBase, System.IDisposable
{
// This member is used by the Validate() method to indicate
// whether the Generate() method should return true or false
// during its next execution.
private bool changed;
// This Method is called if the component is loaded/created.
public Script()
{
// Note: Accessing input or output properties from this method
// will have no effect as they have not been allocated yet.
}
// This Method is called if the component is unloaded/disposed
public virtual void Dispose()
{
}
// This Method is called if an input property has changed its value
public override void Validate()
{
}
public override bool Generate()
{
if (changed)
{
changed = false;
return true;
}
return false;
}
// This Method is called if the function/method SendNow is invoked by the user or a bound event.
// Return true, if this component has to be revalidated!
public bool OnSendNow(int arg)
{string SendersAddress = this.YourEmail;
string ReceiversAddress = this.SendToEmail;
string SendersPassword = this.EmailPassword;
string subject = this.Subject;
string body = this.EmailBody;
try
{
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp server";
smtp.Port = 587;
smtp.EnableSsl = false; //or true
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(SendersAddress, SendersPassword);
smtp.Timeout = 30000;
MailMessage message = new MailMessage(SendersAddress, ReceiversAddress, subject, body);
//Disable these 3 lines if no attachments
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment(EmailAttachment);
message.Attachments.Add(attachment);
//Above 3
smtp.SendAsync(message, ""); // no error checking is carried out. Need to look at the MSDN site for more details
this.MessageSent = ("Message Sent Successfully");
Exception = "";// Clear the exception if succesful send
}
catch (Exception ex)
{
this.Exception = (ex.Message);
}
changed = true;
return false;
}
}
Hello Ventuzians!
THE FORUMS ARE CLOSED!
Please join our discord server HERE!! << click me
We are shutting our Ventuz Forum, but don't worry, it will all be archived for you to search in if you have a query. From now on, please add all your comments, questions or observations into our Discord Server
Thanks for the great time - see you on discord!!
Dee, Karol, Daniel and the whoooole Product and Support team!
THE FORUMS ARE CLOSED!
Please join our discord server HERE!! << click me

We are shutting our Ventuz Forum, but don't worry, it will all be archived for you to search in if you have a query. From now on, please add all your comments, questions or observations into our Discord Server
Thanks for the great time - see you on discord!!
Dee, Karol, Daniel and the whoooole Product and Support team!
C sharp script help
Moderator: Support
Re: C sharp script help
No Problems!
Also found this as a good example of how it works. They also have an excellent C# tutorial on their site...
http://www.blackwasp.co.uk/SendSmtpAsync.aspx
Regards
Peter
Also found this as a good example of how it works. They also have an excellent C# tutorial on their site...
http://www.blackwasp.co.uk/SendSmtpAsync.aspx
Regards
Peter
-
- Posts: 666
- Joined: 18 Jan 2012, 20:56
- Location: wuppertal
- Contact:
Re: C sharp script help
hi chris, hi peter
just get it work one hour before
thanks for all hints!
greetz
christian
just get it work one hour before

thanks for all hints!
greetz
christian