Dart.Mail Namespace > MailMessage Class : ReplyAll Method |
Public Function ReplyAll( _ ByVal from As String, _ ByVal text As String _ ) As MailMessage
Dim instance As MailMessage Dim from As String Dim text As String Dim value As MailMessage value = instance.ReplyAll(from, text)
public MailMessage ReplyAll( string from, string text )
public: MailMessage* ReplyAll( string* from, string* text )
public: MailMessage^ ReplyAll( String^ from, String^ text )
Exception | Description |
---|---|
System.FormatException | Bad address format. |
Useful for situations (such as automation) where the original parts should be left unmodified. For a more UI-centric reply method, use ReplyAllInline.
The MailMessage is cloned and the 'text' parameter used to initialize a new Textpart which is inserted as Part[0]. The new message is addressed to the "Reply-To" or "From:" header field found in the original message ("Reply-To" supersedes "From:). All other recipients are added to Cc. "Re: " is prepended to the Subject.
This method does not modify the original message. Use Reply to reply to only the sender. Use Forward to forward the message.
The returned message can be modified to change any default values.
//Queued response messages ready for sending List<MailMessage> queuedMessages = new List<MailMessage>(); private void autoReply(object sender) { //Configure server and account info pop1.Session.RemoteEndPoint = new Dart.Mail.IPEndPoint(myServer, Pop.GetDefaultPort(pop1.Session)); pop1.Session.Username = myUsername; pop1.Session.Password = myPassword; //Connect and log into the account pop1.Connect(); pop1.Authenticate(true, true); //Get header for each message in the account and create response according to subject foreach (PopMessage popMessage in pop1.Messages) { popMessage.Get(0); string code = popMessage.Message.Subject; //If message contains a specific subject, get entire message then queue an automated response message switch (code) { case "ALERT": popMessage.Get(); //Create a reply message and add it to a list of messages to be sent MailMessage replyMessage = popMessage.Message.Reply(fromAddress, "Message acknowledged."); queuedMessages.Add(replyMessage); break; case "ALERT ACK ALL": popMessage.Get(); //Create a reply-all message and add it to a list of messages to be sent MailMessage replyAllMessage = popMessage.Message.ReplyAll(fromAddress, "Message acknowledged to all."); queuedMessages.Add(replyAllMessage); break; case "ALERT ELEVATE": popMessage.Get(); //Create a forward message and add it to a list of messages to be sent MailMessage forwardMessage = popMessage.Message.Forward(fromAddress, supervisorAddress, "Elevated. Please see message below.", ForwardFormat.Standard); queuedMessages.Add(forwardMessage); break; case "ALERT INFORM": popMessage.Get(); //Create a redirect message and add it to a list of messages to be sent MailMessage redirectMessage = popMessage.Message.Forward(fromAddress, colleagueAddress, "Redirected. Please see included message.", ForwardFormat.Redirect); queuedMessages.Add(redirectMessage); break; default: break; } } //Gracefully logout pop1.Close(); //Send queued responses (not implemented in this snippet) sendResponses(); } private void sendResponses() { //Configure server and account info smtp1.Session.RemoteEndPoint = new IPEndPoint(myServer, Smtp.GetDefaultPort(smtp1.Session)); smtp1.Session.Username = myUsername; smtp1.Session.Password = myPassword; //Send all messages in the responses list foreach (MailMessage message in queuedMessages) smtp1.Send(message); queuedMessages.Clear(); //Gracefully logout smtp1.Close(); }
'Queued response messages ready for sending Private queuedMessages As New List(Of MailMessage)() Private Sub autoReply(ByVal sender As Object) 'Configure server and account info pop1.Session.RemoteEndPoint = New Dart.Mail.IPEndPoint(myServer, Pop.GetDefaultPort(pop1.Session)) pop1.Session.Username = myUsername pop1.Session.Password = myPassword 'Connect and log into the account pop1.Connect() pop1.Authenticate(True, True) 'Get header for each message in the account and create response according to subject For Each popMessage As PopMessage In pop1.Messages popMessage.Get(0) Dim code As String = popMessage.Message.Subject 'If message contains a specific subject, get entire message then queue an automated response message Select Case code Case "ALERT" popMessage.Get() 'Create a reply message and add it to a list of messages to be sent Dim replyMessage As MailMessage = popMessage.Message.Reply(fromAddress, "Message acknowledged.") queuedMessages.Add(replyMessage) Case "ALERT ACK ALL" popMessage.Get() 'Create a reply-all message and add it to a list of messages to be sent Dim replyAllMessage As MailMessage = popMessage.Message.ReplyAll(fromAddress, "Message acknowledged to all.") queuedMessages.Add(replyAllMessage) Case "ALERT ELEVATE" popMessage.Get() 'Create a forward message and add it to a list of messages to be sent Dim forwardMessage As MailMessage = popMessage.Message.Forward(fromAddress, supervisorAddress, "Elevated. Please see message below.", ForwardFormat.Standard) queuedMessages.Add(forwardMessage) Case "ALERT INFORM" popMessage.Get() 'Create a redirect message and add it to a list of messages to be sent Dim redirectMessage As MailMessage = popMessage.Message.Forward(fromAddress, colleagueAddress, "Redirected. Please see included message.", ForwardFormat.Redirect) queuedMessages.Add(redirectMessage) Case Else End Select Next popMessage 'Gracefully logout pop1.Close() 'Send queued responses (not implemented in this snippet) sendResponses() End Sub Private Sub sendResponses() 'Configure server and account info smtp1.Session.RemoteEndPoint = New IPEndPoint(myServer, Smtp.GetDefaultPort(smtp1.Session)) smtp1.Session.Username = myUsername smtp1.Session.Password = myPassword 'Send all messages in the responses list For Each message As MailMessage In queuedMessages smtp1.Send(message) Next message queuedMessages.Clear() 'Gracefully logout smtp1.Close() End Sub