public S3TraceListener(string initializeData) { string[] commands = initializeData.Split(','); foreach (var command in commands) { string[] subcommand = command.Split('='); switch (subcommand[0]) { case "logfile": LogFileName = string.Format("{0}.{1}.log", GetUnixTime(), subcommand[1]); break; case "bucket": _bucketName = subcommand[1]; break; } } if (LogFileName == null || _bucketName == null) { throw new Exception("Not valid parameters. Pass logfile=,bucketname=."); } if (_amazonConfig == null) { _amazonConfig = new EnvironmentAWSCredentials(); _s3Client = new AmazonS3Client(_amazonConfig); _stringFile = new List<string>(); } }
/// <summary> /// Default Constructor /// </summary> public MainPage() { InitializeComponent(); this.DataContext = this; AWSCredentials credentials = new EnvironmentAWSCredentials(); sqs = new AmazonSQSClient(credentials); this.PropertyChanged += delegate(object sender, PropertyChangedEventArgs e) { if (string.Compare(e.PropertyName, "SelectedQueueIndex", System.StringComparison.OrdinalIgnoreCase) == 0) { if (_selectedQueueIndex > -1) { this.QueueName = this.QueueNames[_selectedQueueIndex]; this.HaveQueueUrl = true; } } }; }
static void Main(string[] args) { Console.WriteLine("Press any key to send mail!"); Console.ReadKey(); //Getting AWS credentials from App.config //note: see the app.config to get a example var credentials = new EnvironmentAWSCredentials(); //Client SES instantiated var client = new AmazonSimpleEmailServiceClient(credentials, RegionEndpoint.USEast1); var mimeMessage = new MimeMessage(); //Add sender e-mail address //Note: this e-mail address must to be allowed and checked by AWS SES mimeMessage.From.Add(new MailboxAddress("Test Sender", "*****@*****.**")); //Add e-mail address destiny mimeMessage.To.Add(new MailboxAddress("Joel", "*****@*****.**")); mimeMessage.Subject = "Test"; //Getting attachment stream var fileBytes = File.ReadAllBytes(@"C:\anyfile.pdf"); var bodyBuilder = new BodyBuilder(); bodyBuilder.TextBody = "Testing the body message"; //You must to inform the mime-type of the attachment and his name bodyBuilder.Attachments.Add("AnyAttachment.pdf", fileBytes, new ContentType("application", "pdf")); mimeMessage.Body = bodyBuilder.ToMessageBody(); //Map MimeMessage to MemoryStream, that is what SenRawEmailRequest accepts var rawMessage = new MemoryStream(); mimeMessage.WriteTo(rawMessage); client.SendRawEmail(new SendRawEmailRequest(new RawMessage(rawMessage))); Console.WriteLine("Email Sended"); Console.ReadKey(); }