private void SetRecipient(GXMailRecipientCollection gXMailRecipientCollection, EmailAddressCollection emailAddressCollection) { foreach (var to in emailAddressCollection) { gXMailRecipientCollection.Add(new GXMailRecipient(to.Name, to.Address)); } }
private void SetRecipient(EmailAddressCollection emailAddressCollection, GXMailRecipientCollection gXMailRecipientCollection) { foreach (GXMailRecipient to in gXMailRecipientCollection) { emailAddressCollection.Add(new EmailAddress(to.Name, to.Address)); } }
private void CopyRecipients(Recipients fromList, GXMailRecipientCollection toList, RecipientType type) { GXLogging.Debug(log, "Copying Recipients: " + type); for (int i = 1; i <= fromList.Count; i++) { Recipient recipient = fromList[i]; if (recipient.Type == (int)type) { toList.Add(new GXMailRecipient(recipient.Name, recipient.Address)); } } }
private void SendAllRecipients(GXMailRecipientCollection coll, string cmd) { if (coll.Count > 0) { List <string> addresses = new List <string>(); foreach (GXMailRecipient recipient in coll) { addresses.Add(GetRecipientAsString(recipient)); } SendNL(cmd + ":" + String.Join(",", addresses.ToArray())); } }
private void CopyRecipients(Recipients fromList, GXMailRecipientCollection toList, RecipientType type) { GXLogging.Debug(log, "Copying Recipients: " + type); for (int i = 1; i <= (int)fromList.Count; i++) { Recipient recipient = (Recipient)fromList.get_Item(i); if (((int)recipient.Type) == (int)type) { toList.Add(new GXMailRecipient(recipient.Name.ToString(), recipient.Address.ToString())); } } }
private void SendRecipientList(GXMailRecipientCollection recipients) { try { foreach (GXMailRecipient recipient in recipients) { SendAndWaitResponse("RCPT TO: <" + recipient.Address + ">"); } } catch (GXMailException exc) { throw new GXMailException(exc.Message, MAIL_InvalidRecipient); } }
private void CopyRecipients(GXMailRecipientCollection fromList, Recipients toList, RecipientType type) { GXLogging.Debug(log, "Copying Recipients: " + type); foreach (GXMailRecipient recipient in fromList) { try { Recipient newRecipient = (Recipient)toList.Add(recipient.Name, optional, (int)type, optional); newRecipient.Resolve(optional); } catch (Exception exc) { GXLogging.Error(log, "Invalid recipient " + recipient.Name, exc); throw new GXMailException("Invalid recipient " + recipient.Name, 14); } } }
public void SetMessageRecipients(GXMailRecipientCollection recipients, string type) { string recsStr = GetField(type); if (!string.IsNullOrEmpty(recsStr)) { bool inQuotes = false; List <String> recPartList = new List <string>(); StringBuilder part = new StringBuilder(); foreach (char c in recsStr) { if (c == '"') { inQuotes = !inQuotes; } if ((c == ';' || c == ',') && !inQuotes) { recPartList.Add(part.ToString()); part = new StringBuilder(); } else { part.Append(c); } } if (part.Length > 0) { recPartList.Add(part.ToString()); } foreach (string recipient in recPartList) { if (!string.IsNullOrEmpty(recipient.Trim())) { string[] recipParts = GetMessageRecipient(recipient); recipients.Add(new GXMailRecipient(recipParts[0], recipParts[1])); } } } }
private void CopyRecipients(GXMailRecipientCollection fromList, Recipients toList, RecipientType type) { GXLogging.Debug(log, "Copying Recipients: " + type); foreach (GXMailRecipient recipient in fromList) { Recipient newRecipient = null; try { newRecipient = toList.Add(recipient.Name); newRecipient.Type = (int)type; } catch (System.Exception exc) { GXLogging.Error(log, "Invalid recipient " + recipient.Name, exc); throw new GXMailException("Invalid recipient " + recipient.Name, 14); } if (newRecipient == null) { GXLogging.Error(log, "Invalid recipient " + recipient.Name); throw new GXMailException("Invalid recipient " + recipient.Name, 14); } } }
private void Receive(GXMailMessage msg) { if (lastReadMessage == count) { throw new NoMessagesException(); } msg.Clear(); char pSep = System.IO.Path.DirectorySeparatorChar; if (!attachDir.EndsWith(pSep.ToString())) { attachDir += pSep.ToString(); } SendNL("RETR " + (++lastReadMessage)); GXLogging.Debug(log, "Receive " + lastReadMessage); MailMessage message = null; try { mailReader = new RFC822Reader(new RFC822EndReader(new SecureNetworkStream(connection))); message = new MailMessage(mailReader, attachDir, readerTimeout); message.DownloadAttachments = this.DownloadAttachments; message.ReadAllMessage(); } catch (InvalidMessageException ime) { #if DEBUG GXLogging.Error(log, "Receive error", ime); #endif throw new GXMailException(ime.Message, GXInternetConstants.MAIL_InvalidValue); } catch (CouldNotSaveAttachmentException dae) { #if DEBUG GXLogging.Error(log, "Receive error", dae); #endif throw new GXMailException(dae.Message, GXInternetConstants.MAIL_CantSaveAttachment); } catch (InvalidAttachmentException iae) { #if DEBUG GXLogging.Error(log, "Receive error", iae); #endif throw new GXMailException(iae.Message, GXInternetConstants.MAIL_InvalidAttachment); } catch (TimeoutExceededException toe) { #if DEBUG GXLogging.Error(log, "Receive error", toe); #endif throw new GXMailException(toe.Message, GXInternetConstants.MAIL_TimeoutExceeded); } catch (Exception exc) { #if DEBUG GXLogging.Error(log, "Receive error", exc); #endif throw new GXMailException(exc.Message, MailConstants.MAIL_ConnectionLost); } try { if (message != null) { GXMailRecipientCollection msgFrom = new GXMailRecipientCollection(); message.SetMessageRecipients(msgFrom, GXInternetConstants.FROM); if (msgFrom.Count > 0) { msg.From = msgFrom.Item(1); } message.SetMessageRecipients(msg.ReplyTo, GXInternetConstants.REPLY_TO); message.SetMessageRecipients(msg.To, GXInternetConstants.TO); message.SetMessageRecipients(msg.CC, GXInternetConstants.CC); msg.Headers = message.Keys; msg.DateSent = message.GetDateSent(); msg.DateReceived = message.GetDateReceived(); msg.Subject = message.GetMessageSubject(); msg.Text = message.GetMessageText(); msg.HTMLText = message.GetMessageHtmlText(); message.SetMessageAttachments(msg.Attachments); } } catch (Exception exc) { GXLogging.Error(log, "Error Receiving", exc); throw new GXMailException(exc.Message, GXInternetConstants.MAIL_InvalidValue); } }