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
C sharp script help
hi all,
I have been looking on line and found a c script for emailing via gmail a file but not sure how to integrate into scene, so I can email snap shots using the script.
using System;
using System.Windows.Forms;
using System.Net.Mail;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("your_email_address@gmail.com");
mail.To.Add("to_address");
mail.Subject = "Test Mail - 1";
mail.Body = "mail with attachment";
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment("your attachment file");
mail.Attachments.Add(attachment);
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
MessageBox.Show("mail Send");
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
I have been looking on line and found a c script for emailing via gmail a file but not sure how to integrate into scene, so I can email snap shots using the script.
using System;
using System.Windows.Forms;
using System.Net.Mail;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com");
mail.From = new MailAddress("your_email_address@gmail.com");
mail.To.Add("to_address");
mail.Subject = "Test Mail - 1";
mail.Body = "mail with attachment";
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment("your attachment file");
mail.Attachments.Add(attachment);
SmtpServer.Port = 587;
SmtpServer.Credentials = new System.Net.NetworkCredential("username", "password");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
MessageBox.Show("mail Send");
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
}
}
}
Re: C sharp script help
Hi Hashim,
I'm still in the early stage of C# but ive been having a go at this
I think i found the post that you referenced your code from and i couldn't get it to work in visual studio, so i picked up another bit of code and had a go with that
I have successfully sent email from visual studio with this code so have transferred it in to Ventuz to do some testing.
after some hours of compiling errors in Ventuz i have now got a code that is returning zero compile errors in the script node (getting there
)
But.....and its a big but.....i still haven't been able to send a test email from Ventuz......
So I too am now wondering if anyone can point out where this script is going wrong in order to achieve said task
See attached file
If theres any prob with attachment, heres the code so far.....
added to Validate()......
inputs added to script node:
strings: YourEmail, SendToEmail, EmailPassword, Subject, EmailBody
Bool: Update
Outputs added to script node:
Strings: Exception, MessageSent
using System.Net;
using System.Net.Mail;
using System.Web;
{
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.Gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(SendersAddress, SendersPassword);
smtp.Timeout = 30000;
MailMessage message = new MailMessage(SendersAddress, ReceiversAddress, subject, body);
smtp.Send(message);
this.MessageSent = ("Message Sent Successfully");
}
catch (Exception ex)
{
this.Exception = (ex.Message);
}
changed = true;
}
hopefully we can get this sorted

Cheers
Chris
p.s didn't get attachement working either, which i know is what you want the script for.......so any ideas on that would be awesome
I'm still in the early stage of C# but ive been having a go at this

I think i found the post that you referenced your code from and i couldn't get it to work in visual studio, so i picked up another bit of code and had a go with that

I have successfully sent email from visual studio with this code so have transferred it in to Ventuz to do some testing.
after some hours of compiling errors in Ventuz i have now got a code that is returning zero compile errors in the script node (getting there

But.....and its a big but.....i still haven't been able to send a test email from Ventuz......
So I too am now wondering if anyone can point out where this script is going wrong in order to achieve said task

See attached file

If theres any prob with attachment, heres the code so far.....
added to Validate()......
inputs added to script node:
strings: YourEmail, SendToEmail, EmailPassword, Subject, EmailBody
Bool: Update
Outputs added to script node:
Strings: Exception, MessageSent
using System.Net;
using System.Net.Mail;
using System.Web;
{
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.Gmail.com";
smtp.Port = 587;
smtp.EnableSsl = true;
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.Credentials = new NetworkCredential(SendersAddress, SendersPassword);
smtp.Timeout = 30000;
MailMessage message = new MailMessage(SendersAddress, ReceiversAddress, subject, body);
smtp.Send(message);
this.MessageSent = ("Message Sent Successfully");
}
catch (Exception ex)
{
this.Exception = (ex.Message);
}
changed = true;
}
hopefully we can get this sorted


Cheers
Chris
p.s didn't get attachement working either, which i know is what you want the script for.......so any ideas on that would be awesome

Re: C sharp script help
oooops.....forgot file 

- Attachments
-
- GmailFromVentuz.vza
- (6.96 KiB) Downloaded 622 times
- Daniel Willer
- Posts: 309
- Joined: 06 Jan 2012, 18:12
Re: C sharp script help
It works fine for me just paste your code in a method created via the CustomModel.
Cherio!
Cherio!
Re: C sharp script help
It works! excellent! cheers Daniel (got your email
)
now i will have a look at the attach file option and come back with a working answer....hopefully
chris

now i will have a look at the attach file option and come back with a working answer....hopefully

chris
Re: C sharp script help
add this just before .......smtp.send(message);
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment(@"C:\Users\the file URL goes here");
message.Attachments.Add(attachment);

solved.....
Chris
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment(@"C:\Users\the file URL goes here");
message.Attachments.Add(attachment);

solved.....

Chris
Re: C sharp script help
Nice bit of scripting which as a new C# user I could just about understand.
Does your render stall when sending the email? How can this be avoided?
Regards
Peter
Does your render stall when sending the email? How can this be avoided?
Regards
Peter
Re: C sharp script help
Answering my own question...
Simple really, use sendasync to send the mail!
Peter
Simple really, use sendasync to send the mail!
Peter
Re: C sharp script help
cool iv'e tried to understand the sendasync, looking at link
http://msdn.microsoft.com/en-us/library ... async.aspx
but i have no idea how to add to script any help
http://msdn.microsoft.com/en-us/library ... async.aspx
but i have no idea how to add to script any help
