private void Send(GXMailMessage msg) { GXLogging.Debug(log, "Sending Message"); if (loggedIn) { if (editWindow < 0 || editWindow > 1) { GXLogging.Error(log, "Invalid EditWindow value"); throw new GXMailException("Invalid EditWindow value", 28); } if (msg.To.Count == 0) { GXLogging.Error(log, "No main recipient specified"); throw new GXMailException("No main recipient specified", 13); } Folder outbox = null; try { outbox = (Folder)session.Outbox; } catch (Exception exc) { GXLogging.Error(log, "Not logged in", exc); throw new GXMailException("Not logged in", 2); } if (outbox != null) { try { Messages messages = (Messages)outbox.Messages; Message newMessage = (Message)messages.Add(msg.Subject, msg.Text, optional, optional); CopyRecipients(msg.To, (Recipients)newMessage.Recipients, RecipientType.TO); CopyRecipients(msg.CC, (Recipients)newMessage.Recipients, RecipientType.CC); CopyRecipients(msg.BCC, (Recipients)newMessage.Recipients, RecipientType.BCC); CopyAttachments(msg.Attachments, (Attachments)newMessage.Attachments); newMessage.Send(optional, (bool)(editWindow == 1), optional); session.DeliverNow(); } catch (Exception exc) { GXLogging.Error(log, "Could not send message", exc); throw new GXMailException("Could not send message", 10); } } } else { GXLogging.Error(log, "Not logged in"); throw new GXMailException("Not logged in", 2); } }