예제 #1
0
        public MailMessageItem ToMailMessageItem(int tenant, string user)
        {
            Address from_verified;
            if (Validator.ValidateSyntax(From))
                from_verified = new Address(From, DisplayName);
            else
                throw new ArgumentException(MailApiResource.ErrorIncorrectEmailAddress
                                   .Replace("%1", MailApiResource.FieldNameFrom));

            var message_item = new MailMessageItem
                {
                    From = from_verified.ToString(),
                    FromEmail = from_verified.Email,
                    To = string.Join(", ", To.ToArray()),
                    Cc = Cc != null ? string.Join(", ", Cc.ToArray()) : "",
                    Bcc = Bcc != null ? string.Join(", ", Bcc.ToArray()) : "",
                    Subject = Subject,
                    Date = DateTime.Now,
                    Important = Important,
                    HtmlBody = HtmlBody,
                    Introduction = MailMessageItem.GetIntroduction(HtmlBody),
                    StreamId = StreamId,
                    TagIds = Labels != null && Labels.Count != 0 ? new ItemList<int>(Labels) : null,
                    Size = HtmlBody.Length
                };

            if (message_item.Attachments == null) 
                message_item.Attachments = new List<MailAttachment>();

            Attachments.ForEach(attachment => { attachment.tenant = tenant; attachment.user = user; });

            message_item.Attachments.AddRange(Attachments);
            return message_item;
        }
예제 #2
0
 public Envelope(Envelope env)
 {
     _from      = new ActiveUp.Net.Mail.Address();
     Answered   = env.Answered;
     Date       = env.Date;
     DateString = env.DateString;
     Forwarded  = env.Forwarded;
     From       = env.From;
     Id         = env.Id;
     Mailbox    = env.Mailbox;
     Marked     = env.Marked;
     Read       = env.Read;
     Size       = env.Size;
     Subject    = env.Subject;
 }
예제 #3
0
 public WebMailMessage()
 {
     _from = new ActiveUp.Net.Mail.Address();
 }
예제 #4
0
 public IAsyncResult BeginMailFrom(Address address, AsyncCallback callback)
 {
     return this.BeginMailFrom(address.Email, callback);
 }
예제 #5
0
		/// <summary>
		/// Merge the Address collection with the specified datasource.
		/// </summary>
		/// <param name="address">The address to merge.</param>
		/// <param name="dataSource">The datasource to use for merging.</param>
		/// <returns>The merged Address collection</returns>
		public Address MergeAddress(Address address, object dataSource)
		{
			if (address != null)
			{
				address.Name = MergeText(address.Name, dataSource,false);
				address.Email = MergeText(address.Email, dataSource,false);

				return address;
			}

			return null;
		}
예제 #6
0
		/*/// <summary>
		/// Process the Text template.
		/// </summary>
		private void ProcessTextTemplate(string content)
		{
			ActiveUp.Net.Mail.Logger.AddEntry("Processing the TEXT template.", 1);

			// Initialize strings to be used later
			string line = string.Empty, lineUpper = string.Empty;

			// Initialize the StringReader to read line per line
			StringReader reader = new StringReader(content);

			// Initialize the actual body count
			int bodyCount = _bodies.Count, lineNumber = 0;

			// Read and parse each line. Append the data in the properties.
			while (reader.Peek() > -1) 
			{
				ActiveUp.Net.Mail.Logger.AddEntry("Line parsed. Body count: + " + bodyCount.ToString() + ".", 0);

				line = reader.ReadLine();
				lineNumber++;
				lineUpper = line.ToUpper();
				
				// If a property, then set value	
				if (lineUpper.StartsWith("TO:"))
				{
					ActiveUp.Net.Mail.Logger.AddEntry("TO property found: + " + line + " (raw).", 0);
					this.Message.To.Add(Parser.ParseAddress(ExtractValue(line)));
				}
				else if (lineUpper.StartsWith("BCC:"))
				{
					ActiveUp.Net.Mail.Logger.AddEntry("BCC property found: + " + line + " (raw).", 0);
					this.Message.Bcc.Add(Parser.ParseAddress(ExtractValue(line)));
				}
				else if (lineUpper.StartsWith("CC:"))
				{
					ActiveUp.Net.Mail.Logger.AddEntry("CC property found: + " + line + " (raw).", 0);
					this.Message.Cc.Add(Parser.ParseAddress(ExtractValue(line)));
				}
				else if (lineUpper.StartsWith("FROM:"))
				{
					ActiveUp.Net.Mail.Logger.AddEntry("FROM property found: + " + line + " (raw).", 0);
					this.Message.From = Parser.ParseAddress(ExtractValue(line));
				}
				else if (lineUpper.StartsWith("SUBJECT:"))
				{
					ActiveUp.Net.Mail.Logger.AddEntry("SUBJECT property found: + " + line + " (raw).", 0);
					this.Message.Subject += ExtractValue(line);
				}
				else if (lineUpper.StartsWith("SMTPSERVER:"))
				{
					ActiveUp.Net.Mail.Logger.AddEntry("SMTPSERVER property found: + " + line + " (raw).", 0);
					this.SmtpServers.Add(ExtractValue(line), 25);
				}
				else if (lineUpper.StartsWith("BODYTEXT:"))
				{
					ActiveUp.Net.Mail.Logger.AddEntry("BODYTEXT property found: + " + line + " (raw).", 0);
					this.Bodies.Add(ExtractValue(line), BodyFormat.Text);
					bodyCount++;
				}
				else if (lineUpper.StartsWith("BODYHTML:"))
				{
					ActiveUp.Net.Mail.Logger.AddEntry("BODYHTML property found: + " + line + " (raw).", 0);
					this.Bodies.Add(ExtractValue(line), BodyFormat.Html);
					bodyCount++;
				}
				else if (lineUpper.StartsWith("FIELDFORMAT:") && lineUpper.IndexOf("=") > -1)
				{
					ActiveUp.Net.Mail.Logger.AddEntry("FIELDFORMAT property found: + " + line + " (raw).", 0);
					this.FieldsFormats.Add(ExtractFormat(line));
				}
				else if (lineUpper.StartsWith("//"))
				{
					ActiveUp.Net.Mail.Logger.AddEntry("COMMENT line found: + " + line + " (raw).", 0);
					// Line is a comment, so do nothing
				}
					// If not a property, then it's a message line
				else
				{
					ActiveUp.Net.Mail.Logger.AddEntry("BODY line found: + " + line + " (raw).", 0);
					this.Bodies[bodyCount-1].Content += line + "\r\n";					
				}
			}
		}*/

		/*/// <summary>
		/// Extract the format options from a text template line.
		/// </summary>
		/// <param name="line">The text template line.</param>
		/// <returns>A FieldFormat object with the options.</returns>
		private FieldFormat ExtractFormat(string line)
		{
			ActiveUp.Net.Mail.Logger.AddEntry("Extracting FieldFormat from line: + " + line + " (raw).", 0);
			
			FieldFormat fieldFormat = new FieldFormat();
			string property, val;

			foreach(string format in ExtractValue(line).Split(';'))
			{
				string[] lineSplit = format.Split('=');
				
				if (lineSplit.Length > 1)
				{
					property = lineSplit[0];
					val = lineSplit[1];

					switch (property.ToUpper())
					{
						case "NAME": fieldFormat.Name = val; break;
						case "FORMAT": fieldFormat.Format = val; break;
						case "PADDINGDIR":
							if (val.ToUpper() == "LEFT")
								fieldFormat.PaddingDir = PaddingDirection.Left; 
							else
								fieldFormat.PaddingDir = PaddingDirection.Right;
							break;
						case "TOTALWIDTH":
							try
							{
								fieldFormat.TotalWidth = Convert.ToInt16(val);
							}
							catch
							{
								throw new Exception("Specified Total Width is not a valid number.");
							}
							break;
						case "PADDINGCHAR": fieldFormat.PaddingChar = Convert.ToChar(val.Substring(0, 1)); break;
					}

				}// End if line split length > 1
			}

			return fieldFormat;
		}*/

		/// <summary>
		/// Process the Xml template.
		/// </summary>
		private void ProcessXmlTemplate(string content)
		{
			ActiveUp.Net.Mail.Logger.AddEntry("Processing the XML template.", 1);

			StringReader stringReader = new StringReader(content);
			XmlTextReader reader = new XmlTextReader(stringReader);

			string element = string.Empty;

			while (reader.Read())
			{
				switch (reader.NodeType)
				{
					case XmlNodeType.Element:
						element = reader.Name;
						ActiveUp.Net.Mail.Logger.AddEntry("New element found: " + element + ".", 0);

					switch (element.ToUpper())
					{
						case "MESSAGE":
						{
							if (reader.GetAttribute("PRIORITY") != null && reader.GetAttribute("PRIORITY") != string.Empty)
								this.Message.Priority = (MessagePriority)Enum.Parse(typeof(MessagePriority), reader.GetAttribute("PRIORITY"), true); 
							else if (reader.GetAttribute("priority") != null && reader.GetAttribute("priority") != string.Empty)
								this.Message.Priority = (MessagePriority)Enum.Parse(typeof(MessagePriority), reader.GetAttribute("priority"), true); 

						} break;

						case "FIELDFORMAT":
							if (reader.HasAttributes)
							{
								ActiveUp.Net.Mail.Logger.AddEntry("Element has attributes.", 0);
								FieldFormat fieldFormat = new FieldFormat();

								if (reader.GetAttribute("NAME") != null && reader.GetAttribute("NAME") != string.Empty)
								{
									fieldFormat.Name = reader.GetAttribute("NAME");
									ActiveUp.Net.Mail.Logger.AddEntry("Attribute NAME: " + fieldFormat.Name, 0);
								}

								else if (reader.GetAttribute("name") != null && reader.GetAttribute("name") != string.Empty)
								{
									fieldFormat.Name = reader.GetAttribute("name");
									ActiveUp.Net.Mail.Logger.AddEntry("Attribute name: " + fieldFormat.Name, 0);
								}

								if (reader.GetAttribute("FORMAT") != null && reader.GetAttribute("FORMAT") != string.Empty)
								{
									fieldFormat.Format = reader.GetAttribute("FORMAT");
									ActiveUp.Net.Mail.Logger.AddEntry("Attribute FORMAT: " + fieldFormat.Format, 0);
								}

								else if (reader.GetAttribute("format") != null && reader.GetAttribute("format") != string.Empty)
								{
									fieldFormat.Format = reader.GetAttribute("format");
									ActiveUp.Net.Mail.Logger.AddEntry("Attribute format: " + fieldFormat.Format, 0);
								}

								if (reader.GetAttribute("PADDINGDIR") != null && reader.GetAttribute("PADDINGDIR") != string.Empty)
								{
									if (reader.GetAttribute("PADDINGDIR").ToUpper() == "LEFT")
										fieldFormat.PaddingDir = PaddingDirection.Left;
									else
										fieldFormat.PaddingDir = PaddingDirection.Right;
									ActiveUp.Net.Mail.Logger.AddEntry("Attribute PADDINGDIR: " + reader.GetAttribute("PADDINGDIR"), 0);
								}

								else if (reader.GetAttribute("paddingdir") != null && reader.GetAttribute("paddingdir") != string.Empty)
								{
									if (reader.GetAttribute("paddingdir").ToUpper() == "left")
										fieldFormat.PaddingDir = PaddingDirection.Left;
									else
										fieldFormat.PaddingDir = PaddingDirection.Right;
									ActiveUp.Net.Mail.Logger.AddEntry("Attribute paddingdir: " + reader.GetAttribute("paddingdir"), 0);
								}

								if (reader.GetAttribute("TOTALWIDTH") != null && reader.GetAttribute("TOTALWIDTH") != string.Empty)
								{
									try
									{
										fieldFormat.TotalWidth = Convert.ToInt16(reader.GetAttribute("TOTALWIDTH"));
									}
									catch
									{
										throw new Exception("Specified Total Width is not a valid number.");
									}
									ActiveUp.Net.Mail.Logger.AddEntry("Attribute TOTALWIDTH: " + fieldFormat.TotalWidth.ToString(), 0);
								}

								else if (reader.GetAttribute("totalwidth") != null && reader.GetAttribute("totalwidth") != string.Empty)
								{
									try
									{
										fieldFormat.TotalWidth = Convert.ToInt16(reader.GetAttribute("totalwidth"));
									}
									catch
									{
										throw new Exception("Specified Total Width is not a valid number.");
									}
									ActiveUp.Net.Mail.Logger.AddEntry("Attribute totalwidth: " + fieldFormat.TotalWidth.ToString(), 0);
								}

								if (reader.GetAttribute("PADDINGCHAR") != null && reader.GetAttribute("PADDINGCHAR") != string.Empty)
								{
									fieldFormat.PaddingChar = Convert.ToChar(reader.GetAttribute("PADDINGCHAR").Substring(0, 1));
									ActiveUp.Net.Mail.Logger.AddEntry("Attribute PADDINGCHAR: '" + fieldFormat.PaddingChar + "'", 0);
								}

								else if (reader.GetAttribute("paddingchar") != null && reader.GetAttribute("paddingchar") != string.Empty)
								{
									fieldFormat.PaddingChar = Convert.ToChar(reader.GetAttribute("paddingchar").Substring(0, 1));
									ActiveUp.Net.Mail.Logger.AddEntry("Attribute paddingchar: '" + fieldFormat.PaddingChar + "'", 0);
								}

								this.FieldsFormats.Add(fieldFormat);
							}
								
							break;
						case "FROM":
						case "TO":
						case "CC":
						case "BCC":
							if (reader.HasAttributes)
							{
								ActiveUp.Net.Mail.Address address = new ActiveUp.Net.Mail.Address();
								if (reader.GetAttribute("NAME") != null && reader.GetAttribute("NAME") != string.Empty)
									address.Name = reader.GetAttribute("NAME");
								else if (reader.GetAttribute("name") != null && reader.GetAttribute("name") != string.Empty)
									address.Name = reader.GetAttribute("name");
								if (reader.GetAttribute("EMAIL") != null && reader.GetAttribute("EMAIL") != string.Empty)
									address.Email = reader.GetAttribute("EMAIL");
								else if (reader.GetAttribute("email") != null && reader.GetAttribute("email") != string.Empty)
									address.Email = reader.GetAttribute("email");
								if (element.ToUpper() == "FROM")
								{
									if (reader.GetAttribute("REPLYNAME") != null && reader.GetAttribute("REPLYNAME") != string.Empty)
									{
										InitReplyTo();
										this.Message.ReplyTo.Name = reader.GetAttribute("REPLYNAME");
									}
									else if (reader.GetAttribute("replyname") != null && reader.GetAttribute("replyname") != string.Empty)
									{
										InitReplyTo();
										this.Message.ReplyTo.Name = reader.GetAttribute("replyname");
									}

									if (reader.GetAttribute("REPLYEMAIL") != null && reader.GetAttribute("REPLYEMAIL") != string.Empty)
									{
										InitReplyTo();
										this.Message.ReplyTo.Email = reader.GetAttribute("REPLYEMAIL");
									}
									else if (reader.GetAttribute("replyemail") != null && reader.GetAttribute("replyemail") != string.Empty)
									{
										InitReplyTo();
										this.Message.ReplyTo.Email = reader.GetAttribute("replyemail");
									}

									if (reader.GetAttribute("RECEIPTEMAIL") != null && reader.GetAttribute("RECEIPTEMAIL") != string.Empty)
									{
										this.Message.ReturnReceipt.Email = reader.GetAttribute("RECEIPTEMAIL");
									}
									else if (reader.GetAttribute("receiptemail") != null && reader.GetAttribute("receiptemail") != string.Empty)
									{
										this.Message.ReturnReceipt.Email = reader.GetAttribute("receiptemail");
									}
								}

								switch (reader.Name.ToUpper())
								{
									case "FROM": /*this.Message.From.Add(address);*/this.Message.From = address; break;
									case "TO": this.Message.To.Add(address); break;
									case "CC": this.Message.Cc.Add(address); break;
									case "BCC": this.Message.Bcc.Add(address); break;
								}
							}
							break;
						case "LISTTEMPLATE":
						{
							ListTemplate template = new ListTemplate(); 
							string RegionID = string.Empty;
							string NullText = string.Empty;
							if (reader.GetAttribute("REGIONID") != null && reader.GetAttribute("REGIONID") != string.Empty)
								RegionID = reader.GetAttribute("REGIONID");
							else if (reader.GetAttribute("regionid") != null && reader.GetAttribute("regionid") != string.Empty)
								RegionID = reader.GetAttribute("regionid");

							if (reader.GetAttribute("NULLTEXT") != null && reader.GetAttribute("NULLTEXT") != string.Empty)
								NullText = reader.GetAttribute("NULLTEXT");
							else if (reader.GetAttribute("nulltext") != null && reader.GetAttribute("nulltext") != string.Empty)
								NullText = reader.GetAttribute("nulltext");

							if (reader.HasAttributes && reader.GetAttribute("NAME") != null && reader.GetAttribute("NAME") != string.Empty)
								template = new ListTemplate(reader.GetAttribute("NAME"), reader.ReadString());
							else if (reader.HasAttributes && reader.GetAttribute("name") != null && reader.GetAttribute("name") != string.Empty)
								template = new ListTemplate(reader.GetAttribute("name"), reader.ReadString());
							
							template.RegionID = RegionID;
							template.NullText = NullText;

							this.ListTemplates.Add(template);

						} break;

						case "SMTPSERVER":
						{
							Server server = new Server(); 

							if (reader.GetAttribute("SERVER") != null && reader.GetAttribute("SERVER") != string.Empty)
								server.Host = reader.GetAttribute("SERVER");
							else if (reader.GetAttribute("server") != null && reader.GetAttribute("server") != string.Empty)
								server.Host = reader.GetAttribute("server");

							if (reader.GetAttribute("PORT") != null && reader.GetAttribute("PORT") != string.Empty)
								server.Port = int.Parse(reader.GetAttribute("PORT"));
							else if (reader.GetAttribute("port") != null && reader.GetAttribute("port") != string.Empty)
								server.Port = int.Parse(reader.GetAttribute("port"));
	
							if (reader.GetAttribute("USERNAME") != null && reader.GetAttribute("USERNAME") != string.Empty)
								server.Username = reader.GetAttribute("USERNAME");
							else if (reader.GetAttribute("username") != null && reader.GetAttribute("username") != string.Empty)
								server.Username = reader.GetAttribute("username");

							if (reader.GetAttribute("PASSWORD") != null && reader.GetAttribute("PASSWORD") != string.Empty)
								server.Password = reader.GetAttribute("PASSWORD");
							else if (reader.GetAttribute("password") != null && reader.GetAttribute("password") != string.Empty)
								server.Password = reader.GetAttribute("password");	

							SmtpServers.Add(server);

						} break;

						case "CONDITION":
						{
							Condition condition = new Condition(); 

							if (reader.GetAttribute("REGIONID") != null && reader.GetAttribute("REGIONID") != string.Empty)
								condition.RegionID = reader.GetAttribute("REGIONID");
							else if (reader.GetAttribute("regionid") != null && reader.GetAttribute("regionid") != string.Empty)
								condition.RegionID = reader.GetAttribute("regionid");

							if (reader.GetAttribute("OPERATOR") != null && reader.GetAttribute("OPERATOR") != string.Empty)
								condition.Operator = (OperatorType)Enum.Parse(typeof(OperatorType), reader.GetAttribute("OPERATOR"), true); 
							else if (reader.GetAttribute("operator") != null && reader.GetAttribute("operator") != string.Empty)
								condition.Operator = (OperatorType)Enum.Parse(typeof(OperatorType), reader.GetAttribute("operator"), true); 

							if (reader.GetAttribute("NULLTEXT") != null && reader.GetAttribute("NULLTEXT") != string.Empty)
								condition.NullText = reader.GetAttribute("NULLTEXT");
							else if (reader.GetAttribute("nulltext") != null && reader.GetAttribute("nulltext") != string.Empty)
								condition.NullText = reader.GetAttribute("nulltext");

							if (reader.GetAttribute("FIELD") != null && reader.GetAttribute("FIELD") != string.Empty)
								condition.Field = reader.GetAttribute("FIELD");
							else if (reader.GetAttribute("field") != null && reader.GetAttribute("field") != string.Empty)
								condition.Field = reader.GetAttribute("field");

							if (reader.GetAttribute("VALUE") != null && reader.GetAttribute("VALUE") != string.Empty)
								condition.Value = reader.GetAttribute("VALUE");
							else if (reader.GetAttribute("value") != null && reader.GetAttribute("value") != string.Empty)
								condition.Value = reader.GetAttribute("value");	

							if (reader.GetAttribute("CASESENSITIVE") != null && reader.GetAttribute("CASESENSITIVE") != string.Empty)
								condition.CaseSensitive = bool.Parse(reader.GetAttribute("CASESENSITIVE"));
							else if (reader.GetAttribute("casesensitive") != null && reader.GetAttribute("casesensitive") != string.Empty)
								condition.CaseSensitive = bool.Parse(reader.GetAttribute("casesensitive"));
	
							Conditions.Add(condition);

						} break;

						case "REGION":
						{
							Region region = new Region(); 

							if (reader.GetAttribute("REGIONID") != null && reader.GetAttribute("REGIONID") != string.Empty)
								region.RegionID = reader.GetAttribute("REGIONID");
							else if (reader.GetAttribute("regionid") != null && reader.GetAttribute("regionid") != string.Empty)
								region.RegionID = reader.GetAttribute("regionid");

							if (reader.GetAttribute("NULLTEXT") != null && reader.GetAttribute("NULLTEXT") != string.Empty)
								region.NullText = reader.GetAttribute("NULLTEXT");
							else if (reader.GetAttribute("nulltext") != null && reader.GetAttribute("nulltext") != string.Empty)
								region.NullText = reader.GetAttribute("nulltext");

							if (reader.GetAttribute("URL") != null && reader.GetAttribute("URL") != string.Empty)
								region.URL = reader.GetAttribute("URL");
							else if (reader.GetAttribute("url") != null && reader.GetAttribute("url") != string.Empty)
								region.URL = reader.GetAttribute("url");

							Regions.Add(region);

						} break;

					} break;
					case XmlNodeType.Text:
					switch (element.ToUpper())
					{
						case "SUBJECT":
							this.Message.Subject += reader.Value;
							break;
						/*case "SMTPSERVER":
							this.SmtpServers.Add(reader.Value, 25);
							break;*/
						case "BODYHTML":
							//this.Bodies.Add(reader.Value, BodyFormat.Html);
							this.Message.BodyHtml.Text += reader.Value;
							break;
						case "BODYTEXT":
							//this.Bodies.Add(reader.Value, BodyFormat.Text);
							this.Message.BodyText.Text += reader.Value;
							break;
					}
						break;
					case XmlNodeType.EndElement:
						element = string.Empty;
						break;
				}       
			}
		}
        /// <summary>
        /// Send a confirmation mail to the address that send in a question
        /// </summary>
        /// <param name="from">Address that send in a question</param>
        private void SendConfirmationMail(Address from)
        {
            //Create the from and to addresses that are needed to send the e-mail
            MailAddress fromAddress = new MailAddress(username, "IntelliCloud Team");
            MailAddress toAddress = new MailAddress(from.Email, from.Name);
            
            //Set the e-mail content
            string subject = "Thank you for your question!";
            string body = "Hello " + from.Name + ",\n\n" + 
                "We received your question. You will soon receive an answer.\n\n" +
                "Kind regards,\n" +
                "IntelliCloud Team";

            //Create a new smtp client with credentials
            SmtpClient smtp = new SmtpClient
            {
                Host = "smtp.gmail.com",
                Port = 587,
                EnableSsl = true,
                DeliveryMethod = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = false,
                Credentials = new NetworkCredential(fromAddress.Address, password)
            };

            //Create the e-mail with the addresses and content
            using (MailMessage message = new MailMessage(fromAddress, toAddress)
            {
                Subject = subject,
                Body = body
            })
            //Send the mail
                try
                {
                    smtp.Send(message);
                }
                catch (Exception e)
                {
                    //If it fails, the error is written to the logfile
                    serviceLog.WriteEntry("Sending e-mail failed: " + e.ToString());
                }
            //Dispose the smtp client
            smtp.Dispose();
        }
예제 #8
0
 public Envelope(Envelope env)
 {
     _from = new ActiveUp.Net.Mail.Address();
     Answered = env.Answered;
     Date = env.Date;
     DateString = env.DateString;
     Forwarded = env.Forwarded;
     From = env.From;
     Id = env.Id;
     Mailbox = env.Mailbox;
     Marked = env.Marked;
     Read = env.Read;
     Size = env.Size;
     Subject = env.Subject;
 }
예제 #9
0
 public static IAsyncResult BeginValidate(Address address, string dnsServerHost, AsyncCallback callback)
 {
     SmtpValidator._delegateValidateAddressString = SmtpValidator.Validate;
     return SmtpValidator._delegateValidateAddressString.BeginInvoke(address, dnsServerHost, callback, SmtpValidator._delegateValidateAddressString);
 }
예제 #10
0
 public WebMailMessage()
 {
     _from = new ActiveUp.Net.Mail.Address();
 }
예제 #11
0
 public static IAsyncResult BeginValidate(Address address, ServerCollection dnsServers, AsyncCallback callback)
 {
     SmtpValidator._delegateValidateAddressServers = SmtpValidator.Validate;
     return SmtpValidator._delegateValidateAddressServers.BeginInvoke(address, dnsServers, callback, SmtpValidator._delegateValidateAddressServers);
 }
예제 #12
0
 /// <summary>
 /// Validates syntax and existence of the given address.
 /// </summary>
 /// <param name="address">The address to be validated.</param>
 /// <param name="dnsServerHost">Name Server to be used for MX records search.</param>
 /// <returns>True if the address is valid, otherwise false.</returns>
 public static bool Validate(Address address, string dnsServerHost)
 {
     ActiveUp.Net.Mail.ServerCollection servers = new ActiveUp.Net.Mail.ServerCollection();
     servers.Add(dnsServerHost, 53);
     return ActiveUp.Net.Mail.SmtpValidator.Validate(address.Email, servers);
 }
예제 #13
0
 /// <summary>
 /// Validates syntax and existence of the given address.
 /// </summary>
 /// <param name="address">The address to be validated.</param>
 /// <param name="dnsServers">Name Servers to be used for MX records search.</param>
 /// <returns>True if the address is valid, otherwise false.</returns>
 public static bool Validate(Address address, ServerCollection dnsServers)
 {
     return SmtpValidator.Validate(address.Email, dnsServers);
 }
예제 #14
0
 public static IAsyncResult BeginValidate(Address address, AsyncCallback callback)
 {
     SmtpValidator._delegateValidateAddress = SmtpValidator.Validate;
     return SmtpValidator._delegateValidateAddress.BeginInvoke(address, callback, SmtpValidator._delegateValidateAddress);
 }
예제 #15
0
 /// <summary>
 /// Validates syntax and existence of the given address.
 /// </summary>
 /// <param name="address">The address to be validated.</param>
 /// <returns>True if the address is valid, otherwise false.</returns>
 public static bool Validate(Address address)
 {
     return SmtpValidator.Validate(address.Email);
 }
예제 #16
0
 public IAsyncResult BeginRcptTo(Address address, AsyncCallback callback)
 {
     return this.BeginRcptTo(address.Email, callback);
 }
예제 #17
0
        /// <summary>
        /// Parses the address.
        /// </summary>
        /// <param name="input">The input.</param>
        /// <returns></returns>
        public static Address ParseAddress(string input)
        {
            var address = new Address();
            input = input.TrimEnd(';');
            try
            {
                if (input.IndexOf("<", StringComparison.Ordinal) == -1) address.Email = RemoveWhiteSpaces(input);
                else
                {
                    foreach (Match match in _regxEmail.Matches(input))
                    {
                        //This needed because only last match is email. SAmple name: name<teamlab>endname<*****@*****.**>.
                        //Two matches: <teamlab>, <*****@*****.**> - only last match - email.
                        // if format like name<*****@*****.**>endname<teamlab>.Its incorrect address.
                        address.Email = match.Value.TrimStart('<').TrimEnd('>');
                    }

                    address.Name = input.Replace("<" + address.Email + ">", "");
                    address.Email = Clean(RemoveWhiteSpaces(address.Email));
                    if (address.Name.IndexOf("\"", StringComparison.Ordinal) == -1) address.Name = Clean(address.Name);
                    address.Name = address.Name.Trim(new[] {' ', '\"'});
                }
                return address;
            }
            catch
            {
                var addr = new MailAddress(input);
                return new Address(addr.Address, addr.DisplayName);
            }
        }
예제 #18
0
 public IAsyncResult BeginVerify(Address address, AsyncCallback callback)
 {
     return this.BeginVerify(address.Email, callback);
 }
예제 #19
0
        /*/// <summary>
         * /// Process the Text template.
         * /// </summary>
         * private void ProcessTextTemplate(string content)
         * {
         *      ActiveUp.Net.Mail.Logger.AddEntry("Processing the TEXT template.", 1);
         *
         *      // Initialize strings to be used later
         *      string line = string.Empty, lineUpper = string.Empty;
         *
         *      // Initialize the StringReader to read line per line
         *      StringReader reader = new StringReader(content);
         *
         *      // Initialize the actual body count
         *      int bodyCount = _bodies.Count, lineNumber = 0;
         *
         *      // Read and parse each line. Append the data in the properties.
         *      while (reader.Peek() > -1)
         *      {
         *              ActiveUp.Net.Mail.Logger.AddEntry("Line parsed. Body count: + " + bodyCount.ToString() + ".", 0);
         *
         *              line = reader.ReadLine();
         *              lineNumber++;
         *              lineUpper = line.ToUpper();
         *
         *              // If a property, then set value
         *              if (lineUpper.StartsWith("TO:"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("TO property found: + " + line + " (raw).", 0);
         *                      this.Message.To.Add(Parser.ParseAddress(ExtractValue(line)));
         *              }
         *              else if (lineUpper.StartsWith("BCC:"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("BCC property found: + " + line + " (raw).", 0);
         *                      this.Message.Bcc.Add(Parser.ParseAddress(ExtractValue(line)));
         *              }
         *              else if (lineUpper.StartsWith("CC:"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("CC property found: + " + line + " (raw).", 0);
         *                      this.Message.Cc.Add(Parser.ParseAddress(ExtractValue(line)));
         *              }
         *              else if (lineUpper.StartsWith("FROM:"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("FROM property found: + " + line + " (raw).", 0);
         *                      this.Message.From = Parser.ParseAddress(ExtractValue(line));
         *              }
         *              else if (lineUpper.StartsWith("SUBJECT:"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("SUBJECT property found: + " + line + " (raw).", 0);
         *                      this.Message.Subject += ExtractValue(line);
         *              }
         *              else if (lineUpper.StartsWith("SMTPSERVER:"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("SMTPSERVER property found: + " + line + " (raw).", 0);
         *                      this.SmtpServers.Add(ExtractValue(line), 25);
         *              }
         *              else if (lineUpper.StartsWith("BODYTEXT:"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("BODYTEXT property found: + " + line + " (raw).", 0);
         *                      this.Bodies.Add(ExtractValue(line), BodyFormat.Text);
         *                      bodyCount++;
         *              }
         *              else if (lineUpper.StartsWith("BODYHTML:"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("BODYHTML property found: + " + line + " (raw).", 0);
         *                      this.Bodies.Add(ExtractValue(line), BodyFormat.Html);
         *                      bodyCount++;
         *              }
         *              else if (lineUpper.StartsWith("FIELDFORMAT:") && lineUpper.IndexOf("=") > -1)
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("FIELDFORMAT property found: + " + line + " (raw).", 0);
         *                      this.FieldsFormats.Add(ExtractFormat(line));
         *              }
         *              else if (lineUpper.StartsWith("//"))
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("COMMENT line found: + " + line + " (raw).", 0);
         *                      // Line is a comment, so do nothing
         *              }
         *                      // If not a property, then it's a message line
         *              else
         *              {
         *                      ActiveUp.Net.Mail.Logger.AddEntry("BODY line found: + " + line + " (raw).", 0);
         *                      this.Bodies[bodyCount-1].Content += line + "\r\n";
         *              }
         *      }
         * }*/

        /*/// <summary>
         * /// Extract the format options from a text template line.
         * /// </summary>
         * /// <param name="line">The text template line.</param>
         * /// <returns>A FieldFormat object with the options.</returns>
         * private FieldFormat ExtractFormat(string line)
         * {
         *      ActiveUp.Net.Mail.Logger.AddEntry("Extracting FieldFormat from line: + " + line + " (raw).", 0);
         *
         *      FieldFormat fieldFormat = new FieldFormat();
         *      string property, val;
         *
         *      foreach(string format in ExtractValue(line).Split(';'))
         *      {
         *              string[] lineSplit = format.Split('=');
         *
         *              if (lineSplit.Length > 1)
         *              {
         *                      property = lineSplit[0];
         *                      val = lineSplit[1];
         *
         *                      switch (property.ToUpper())
         *                      {
         *                              case "NAME": fieldFormat.Name = val; break;
         *                              case "FORMAT": fieldFormat.Format = val; break;
         *                              case "PADDINGDIR":
         *                                      if (val.ToUpper() == "LEFT")
         *                                              fieldFormat.PaddingDir = PaddingDirection.Left;
         *                                      else
         *                                              fieldFormat.PaddingDir = PaddingDirection.Right;
         *                                      break;
         *                              case "TOTALWIDTH":
         *                                      try
         *                                      {
         *                                              fieldFormat.TotalWidth = Convert.ToInt16(val);
         *                                      }
         *                                      catch
         *                                      {
         *                                              throw new Exception("Specified Total Width is not a valid number.");
         *                                      }
         *                                      break;
         *                              case "PADDINGCHAR": fieldFormat.PaddingChar = Convert.ToChar(val.Substring(0, 1)); break;
         *                      }
         *
         *              }// End if line split length > 1
         *      }
         *
         *      return fieldFormat;
         * }*/

        /// <summary>
        /// Process the Xml template.
        /// </summary>
        private void ProcessXmlTemplate(string content)
        {
            ActiveUp.Net.Mail.Logger.AddEntry("Processing the XML template.", 1);

            StringReader  stringReader = new StringReader(content);
            XmlTextReader reader       = new XmlTextReader(stringReader);

            string element = string.Empty;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                case XmlNodeType.Element:
                    element = reader.Name;
                    ActiveUp.Net.Mail.Logger.AddEntry("New element found: " + element + ".", 0);

                    switch (element.ToUpper())
                    {
                    case "MESSAGE":
                    {
                        if (reader.GetAttribute("PRIORITY") != null && reader.GetAttribute("PRIORITY") != string.Empty)
                        {
                            this.Message.Priority = (MessagePriority)Enum.Parse(typeof(MessagePriority), reader.GetAttribute("PRIORITY"), true);
                        }
                        else if (reader.GetAttribute("priority") != null && reader.GetAttribute("priority") != string.Empty)
                        {
                            this.Message.Priority = (MessagePriority)Enum.Parse(typeof(MessagePriority), reader.GetAttribute("priority"), true);
                        }
                    } break;

                    case "FIELDFORMAT":
                        if (reader.HasAttributes)
                        {
                            ActiveUp.Net.Mail.Logger.AddEntry("Element has attributes.", 0);
                            FieldFormat fieldFormat = new FieldFormat();

                            if (reader.GetAttribute("NAME") != null && reader.GetAttribute("NAME") != string.Empty)
                            {
                                fieldFormat.Name = reader.GetAttribute("NAME");
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute NAME: " + fieldFormat.Name, 0);
                            }

                            else if (reader.GetAttribute("name") != null && reader.GetAttribute("name") != string.Empty)
                            {
                                fieldFormat.Name = reader.GetAttribute("name");
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute name: " + fieldFormat.Name, 0);
                            }

                            if (reader.GetAttribute("FORMAT") != null && reader.GetAttribute("FORMAT") != string.Empty)
                            {
                                fieldFormat.Format = reader.GetAttribute("FORMAT");
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute FORMAT: " + fieldFormat.Format, 0);
                            }

                            else if (reader.GetAttribute("format") != null && reader.GetAttribute("format") != string.Empty)
                            {
                                fieldFormat.Format = reader.GetAttribute("format");
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute format: " + fieldFormat.Format, 0);
                            }

                            if (reader.GetAttribute("PADDINGDIR") != null && reader.GetAttribute("PADDINGDIR") != string.Empty)
                            {
                                if (reader.GetAttribute("PADDINGDIR").ToUpper() == "LEFT")
                                {
                                    fieldFormat.PaddingDir = PaddingDirection.Left;
                                }
                                else
                                {
                                    fieldFormat.PaddingDir = PaddingDirection.Right;
                                }
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute PADDINGDIR: " + reader.GetAttribute("PADDINGDIR"), 0);
                            }

                            else if (reader.GetAttribute("paddingdir") != null && reader.GetAttribute("paddingdir") != string.Empty)
                            {
                                if (reader.GetAttribute("paddingdir").ToUpper() == "left")
                                {
                                    fieldFormat.PaddingDir = PaddingDirection.Left;
                                }
                                else
                                {
                                    fieldFormat.PaddingDir = PaddingDirection.Right;
                                }
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute paddingdir: " + reader.GetAttribute("paddingdir"), 0);
                            }

                            if (reader.GetAttribute("TOTALWIDTH") != null && reader.GetAttribute("TOTALWIDTH") != string.Empty)
                            {
                                try
                                {
                                    fieldFormat.TotalWidth = Convert.ToInt16(reader.GetAttribute("TOTALWIDTH"));
                                }
                                catch
                                {
                                    throw new Exception("Specified Total Width is not a valid number.");
                                }
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute TOTALWIDTH: " + fieldFormat.TotalWidth.ToString(), 0);
                            }

                            else if (reader.GetAttribute("totalwidth") != null && reader.GetAttribute("totalwidth") != string.Empty)
                            {
                                try
                                {
                                    fieldFormat.TotalWidth = Convert.ToInt16(reader.GetAttribute("totalwidth"));
                                }
                                catch
                                {
                                    throw new Exception("Specified Total Width is not a valid number.");
                                }
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute totalwidth: " + fieldFormat.TotalWidth.ToString(), 0);
                            }

                            if (reader.GetAttribute("PADDINGCHAR") != null && reader.GetAttribute("PADDINGCHAR") != string.Empty)
                            {
                                fieldFormat.PaddingChar = Convert.ToChar(reader.GetAttribute("PADDINGCHAR").Substring(0, 1));
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute PADDINGCHAR: '" + fieldFormat.PaddingChar + "'", 0);
                            }

                            else if (reader.GetAttribute("paddingchar") != null && reader.GetAttribute("paddingchar") != string.Empty)
                            {
                                fieldFormat.PaddingChar = Convert.ToChar(reader.GetAttribute("paddingchar").Substring(0, 1));
                                ActiveUp.Net.Mail.Logger.AddEntry("Attribute paddingchar: '" + fieldFormat.PaddingChar + "'", 0);
                            }

                            this.FieldsFormats.Add(fieldFormat);
                        }

                        break;

                    case "FROM":
                    case "TO":
                    case "CC":
                    case "BCC":
                        if (reader.HasAttributes)
                        {
                            ActiveUp.Net.Mail.Address address = new ActiveUp.Net.Mail.Address();
                            if (reader.GetAttribute("NAME") != null && reader.GetAttribute("NAME") != string.Empty)
                            {
                                address.Name = reader.GetAttribute("NAME");
                            }
                            else if (reader.GetAttribute("name") != null && reader.GetAttribute("name") != string.Empty)
                            {
                                address.Name = reader.GetAttribute("name");
                            }
                            if (reader.GetAttribute("EMAIL") != null && reader.GetAttribute("EMAIL") != string.Empty)
                            {
                                address.Email = reader.GetAttribute("EMAIL");
                            }
                            else if (reader.GetAttribute("email") != null && reader.GetAttribute("email") != string.Empty)
                            {
                                address.Email = reader.GetAttribute("email");
                            }
                            if (element.ToUpper() == "FROM")
                            {
                                if (reader.GetAttribute("REPLYNAME") != null && reader.GetAttribute("REPLYNAME") != string.Empty)
                                {
                                    InitReplyTo();
                                    this.Message.ReplyTo.Name = reader.GetAttribute("REPLYNAME");
                                }
                                else if (reader.GetAttribute("replyname") != null && reader.GetAttribute("replyname") != string.Empty)
                                {
                                    InitReplyTo();
                                    this.Message.ReplyTo.Name = reader.GetAttribute("replyname");
                                }

                                if (reader.GetAttribute("REPLYEMAIL") != null && reader.GetAttribute("REPLYEMAIL") != string.Empty)
                                {
                                    InitReplyTo();
                                    this.Message.ReplyTo.Email = reader.GetAttribute("REPLYEMAIL");
                                }
                                else if (reader.GetAttribute("replyemail") != null && reader.GetAttribute("replyemail") != string.Empty)
                                {
                                    InitReplyTo();
                                    this.Message.ReplyTo.Email = reader.GetAttribute("replyemail");
                                }

                                if (reader.GetAttribute("RECEIPTEMAIL") != null && reader.GetAttribute("RECEIPTEMAIL") != string.Empty)
                                {
                                    this.Message.ReturnReceipt.Email = reader.GetAttribute("RECEIPTEMAIL");
                                }
                                else if (reader.GetAttribute("receiptemail") != null && reader.GetAttribute("receiptemail") != string.Empty)
                                {
                                    this.Message.ReturnReceipt.Email = reader.GetAttribute("receiptemail");
                                }
                            }

                            switch (reader.Name.ToUpper())
                            {
                            case "FROM": /*this.Message.From.Add(address);*/ this.Message.From = address; break;

                            case "TO": this.Message.To.Add(address); break;

                            case "CC": this.Message.Cc.Add(address); break;

                            case "BCC": this.Message.Bcc.Add(address); break;
                            }
                        }
                        break;

                    case "LISTTEMPLATE":
                    {
                        ListTemplate template = new ListTemplate();
                        string       RegionID = string.Empty;
                        string       NullText = string.Empty;
                        if (reader.GetAttribute("REGIONID") != null && reader.GetAttribute("REGIONID") != string.Empty)
                        {
                            RegionID = reader.GetAttribute("REGIONID");
                        }
                        else if (reader.GetAttribute("regionid") != null && reader.GetAttribute("regionid") != string.Empty)
                        {
                            RegionID = reader.GetAttribute("regionid");
                        }

                        if (reader.GetAttribute("NULLTEXT") != null && reader.GetAttribute("NULLTEXT") != string.Empty)
                        {
                            NullText = reader.GetAttribute("NULLTEXT");
                        }
                        else if (reader.GetAttribute("nulltext") != null && reader.GetAttribute("nulltext") != string.Empty)
                        {
                            NullText = reader.GetAttribute("nulltext");
                        }

                        if (reader.HasAttributes && reader.GetAttribute("NAME") != null && reader.GetAttribute("NAME") != string.Empty)
                        {
                            template = new ListTemplate(reader.GetAttribute("NAME"), reader.ReadString());
                        }
                        else if (reader.HasAttributes && reader.GetAttribute("name") != null && reader.GetAttribute("name") != string.Empty)
                        {
                            template = new ListTemplate(reader.GetAttribute("name"), reader.ReadString());
                        }

                        template.RegionID = RegionID;
                        template.NullText = NullText;

                        this.ListTemplates.Add(template);
                    } break;

                    case "SMTPSERVER":
                    {
                        Server server = new Server();

                        if (reader.GetAttribute("SERVER") != null && reader.GetAttribute("SERVER") != string.Empty)
                        {
                            server.Host = reader.GetAttribute("SERVER");
                        }
                        else if (reader.GetAttribute("server") != null && reader.GetAttribute("server") != string.Empty)
                        {
                            server.Host = reader.GetAttribute("server");
                        }

                        if (reader.GetAttribute("PORT") != null && reader.GetAttribute("PORT") != string.Empty)
                        {
                            server.Port = int.Parse(reader.GetAttribute("PORT"));
                        }
                        else if (reader.GetAttribute("port") != null && reader.GetAttribute("port") != string.Empty)
                        {
                            server.Port = int.Parse(reader.GetAttribute("port"));
                        }

                        if (reader.GetAttribute("USERNAME") != null && reader.GetAttribute("USERNAME") != string.Empty)
                        {
                            server.Username = reader.GetAttribute("USERNAME");
                        }
                        else if (reader.GetAttribute("username") != null && reader.GetAttribute("username") != string.Empty)
                        {
                            server.Username = reader.GetAttribute("username");
                        }

                        if (reader.GetAttribute("PASSWORD") != null && reader.GetAttribute("PASSWORD") != string.Empty)
                        {
                            server.Password = reader.GetAttribute("PASSWORD");
                        }
                        else if (reader.GetAttribute("password") != null && reader.GetAttribute("password") != string.Empty)
                        {
                            server.Password = reader.GetAttribute("password");
                        }

                        SmtpServers.Add(server);
                    } break;

                    case "CONDITION":
                    {
                        Condition condition = new Condition();

                        if (reader.GetAttribute("REGIONID") != null && reader.GetAttribute("REGIONID") != string.Empty)
                        {
                            condition.RegionID = reader.GetAttribute("REGIONID");
                        }
                        else if (reader.GetAttribute("regionid") != null && reader.GetAttribute("regionid") != string.Empty)
                        {
                            condition.RegionID = reader.GetAttribute("regionid");
                        }

                        if (reader.GetAttribute("OPERATOR") != null && reader.GetAttribute("OPERATOR") != string.Empty)
                        {
                            condition.Operator = (OperatorType)Enum.Parse(typeof(OperatorType), reader.GetAttribute("OPERATOR"), true);
                        }
                        else if (reader.GetAttribute("operator") != null && reader.GetAttribute("operator") != string.Empty)
                        {
                            condition.Operator = (OperatorType)Enum.Parse(typeof(OperatorType), reader.GetAttribute("operator"), true);
                        }

                        if (reader.GetAttribute("NULLTEXT") != null && reader.GetAttribute("NULLTEXT") != string.Empty)
                        {
                            condition.NullText = reader.GetAttribute("NULLTEXT");
                        }
                        else if (reader.GetAttribute("nulltext") != null && reader.GetAttribute("nulltext") != string.Empty)
                        {
                            condition.NullText = reader.GetAttribute("nulltext");
                        }

                        if (reader.GetAttribute("FIELD") != null && reader.GetAttribute("FIELD") != string.Empty)
                        {
                            condition.Field = reader.GetAttribute("FIELD");
                        }
                        else if (reader.GetAttribute("field") != null && reader.GetAttribute("field") != string.Empty)
                        {
                            condition.Field = reader.GetAttribute("field");
                        }

                        if (reader.GetAttribute("VALUE") != null && reader.GetAttribute("VALUE") != string.Empty)
                        {
                            condition.Value = reader.GetAttribute("VALUE");
                        }
                        else if (reader.GetAttribute("value") != null && reader.GetAttribute("value") != string.Empty)
                        {
                            condition.Value = reader.GetAttribute("value");
                        }

                        if (reader.GetAttribute("CASESENSITIVE") != null && reader.GetAttribute("CASESENSITIVE") != string.Empty)
                        {
                            condition.CaseSensitive = bool.Parse(reader.GetAttribute("CASESENSITIVE"));
                        }
                        else if (reader.GetAttribute("casesensitive") != null && reader.GetAttribute("casesensitive") != string.Empty)
                        {
                            condition.CaseSensitive = bool.Parse(reader.GetAttribute("casesensitive"));
                        }

                        Conditions.Add(condition);
                    } break;

                    case "REGION":
                    {
                        Region region = new Region();

                        if (reader.GetAttribute("REGIONID") != null && reader.GetAttribute("REGIONID") != string.Empty)
                        {
                            region.RegionID = reader.GetAttribute("REGIONID");
                        }
                        else if (reader.GetAttribute("regionid") != null && reader.GetAttribute("regionid") != string.Empty)
                        {
                            region.RegionID = reader.GetAttribute("regionid");
                        }

                        if (reader.GetAttribute("NULLTEXT") != null && reader.GetAttribute("NULLTEXT") != string.Empty)
                        {
                            region.NullText = reader.GetAttribute("NULLTEXT");
                        }
                        else if (reader.GetAttribute("nulltext") != null && reader.GetAttribute("nulltext") != string.Empty)
                        {
                            region.NullText = reader.GetAttribute("nulltext");
                        }

                        if (reader.GetAttribute("URL") != null && reader.GetAttribute("URL") != string.Empty)
                        {
                            region.URL = reader.GetAttribute("URL");
                        }
                        else if (reader.GetAttribute("url") != null && reader.GetAttribute("url") != string.Empty)
                        {
                            region.URL = reader.GetAttribute("url");
                        }

                        Regions.Add(region);
                    } break;
                    }
                    break;

                case XmlNodeType.Text:
                    switch (element.ToUpper())
                    {
                    case "SUBJECT":
                        this.Message.Subject += reader.Value;
                        break;

                    /*case "SMTPSERVER":
                     *      this.SmtpServers.Add(reader.Value, 25);
                     *      break;*/
                    case "BODYHTML":
                        //this.Bodies.Add(reader.Value, BodyFormat.Html);
                        this.Message.BodyHtml.Text += reader.Value;
                        break;

                    case "BODYTEXT":
                        //this.Bodies.Add(reader.Value, BodyFormat.Text);
                        this.Message.BodyText.Text += reader.Value;
                        break;
                    }
                    break;

                case XmlNodeType.EndElement:
                    element = string.Empty;
                    break;
                }
            }
        }
예제 #20
0
 /// <summary>
 /// Validates the address' syntax.
 /// </summary>
 /// <param name="address">The address to be validated.</param>
 /// <returns>True if syntax is valid, otherwise false.</returns>
 public static bool ValidateSyntax(ActiveUp.Net.Mail.Address address)
 {
     System.Int32.Parse("20", System.Globalization.NumberStyles.HexNumber);
     return(ActiveUp.Net.Mail.Validator.ValidateSyntax(address.Email));
 }
예제 #21
0
        public MailMessageItem ToMailMessageItem(int tennantid, string userid, bool loadAttachments)
        {
            Address From_verified;
            if (Validator.ValidateSyntax(From))
                From_verified = new Address(From, DisplayName);
            else
                throw new ArgumentException(MailServiceResource.ResourceManager.GetString("ErrorIncorrectEmailAddress").Replace("%1", MailServiceResource.ResourceManager.GetString("FieldNameFrom")));

            List<MailAttachment> internalAttachments = new List<MailAttachment>();
            PreprocessHtml(tennantid, internalAttachments);

            MailMessageItem message_item = new MailMessageItem()
            {
                From = From_verified.ToString(),
                From_Email = From_verified.Email,
                To = string.Join(", ", To.ToArray()),
                Cc = Cc != null ? string.Join(", ", Cc.ToArray()) : "",
                Bcc = Bcc != null ? string.Join(", ", Bcc.ToArray()) : "",
                Subject = Subject,
                Date = DateTime.Now,
                Important = Important,
                HtmlBody = HtmlBody,
                StreamId = StreamId,
                TagIds = Labels != null && Labels.Count != 0 ? new ItemList<int>(Labels) : null
            };
            message_item.loadAttachments(Attachments.Select(att => CreateAttachment(tennantid, att, loadAttachments)), false);
            message_item.loadAttachments(internalAttachments.ConvertAll(att => CreateAttachment(tennantid, att, true)), true);

            return message_item;
        }
예제 #22
0
        public static bool TryParseAddress(string input, out Address address)
        {
            address = null;
            try
            {
                address = ParseAddress(input);
                return true;
            }
            catch { }

            return false;
        }
예제 #23
0
 public Envelope()
 {
     _from = new ActiveUp.Net.Mail.Address();
 }
예제 #24
0
 /// <summary>
 /// Parses the address.
 /// </summary>
 /// <param name="input">The input.</param>
 /// <returns></returns>
 public static Address ParseAddress(string input)
 {
     Address address = new Address();
     input = input.TrimEnd(';');
     try
     {
         if (input.IndexOf("<") == -1) address.Email = Parser.RemoveWhiteSpaces(input);
         else
         {
             address.Email = System.Text.RegularExpressions.Regex.Match(input, "<(.|[.])*>").Value.TrimStart('<').TrimEnd('>');
             address.Name = input.Replace("<" + address.Email + ">", "");
             address.Email = Parser.Clean(Parser.RemoveWhiteSpaces(address.Email));
             if (address.Name.IndexOf("\"") == -1) address.Name = Parser.Clean(address.Name);
             address.Name = address.Name.Trim(new char[] { ' ', '\"' });
         }
         return address;
     }
     catch { return new Address(input); }
 }
예제 #25
0
 public Envelope()
 {
     _from = new ActiveUp.Net.Mail.Address();
 }