public static string get_to(SharpMimeMessage mime_message) { string to = ""; if (mime_message.Header.To != null && mime_message.Header.To != "") { to = SharpMimeTools.parserfc2047Header(mime_message.Header.To); // handle multiline to = to.Replace("\t", " "); } return(to); }
public static string get_cc(SharpMimeMessage mime_message) { string cc = ""; if (mime_message.Header.Cc != null && mime_message.Header.Cc != "") { cc = SharpMimeTools.parserfc2047Header(mime_message.Header.Cc); // handle multiline cc = cc.Replace("\t", " "); } return(cc); }
public static string get_subject(SharpMimeMessage mime_message) { string subject = ""; if (mime_message.Header.Subject != null && mime_message.Header.Subject != "") { subject = SharpMimeTools.parserfc2047Header(mime_message.Header.Subject); // handle multiline subject subject = subject.Replace("\t", " "); } else { subject = "[No Subject]"; } return(subject); }
public static string get_from_addr(SharpMimeMessage mime_message) { string from_addr = ""; if (mime_message.Header.From != null && mime_message.Header.From != "") { from_addr = SharpMimeTools.parserfc2047Header(mime_message.Header.From); // handle multiline subject from_addr = from_addr.Replace("\t", " "); } else { from_addr = "[No From]"; } return(from_addr); }
/////////////////////////////////////////////////////////////////////// public static DataRow get_user_datarow_maybe_using_from_addr(SharpMimeMessage mime_message, string from_addr, string username) { DataRow dr = null; string sql = @" select us_id, us_admin, us_username, us_org, og_other_orgs_permission_level, isnull(us_forced_project,0) us_forced_project from users inner join orgs on us_org = og_id where us_username = N'$us'"; // Create a new user from the "from" email address string btnet_service_username = Util.get_setting("CreateUserFromEmailAddressIfThisUsername", ""); if (!string.IsNullOrEmpty(from_addr) && username == btnet_service_username) { // We can do a better job of parsing the from_addr here than we did in btnet_service.exe if (mime_message != null) { if (mime_message.Header.From != null && mime_message.Header.From != "") { from_addr = SharpMimeTools.parserfc2047Header(mime_message.Header.From); // handle multiline from from_addr = from_addr.Replace("\t", " "); } } // See if there's already a username that matches this email address username = Email.simplify_email_address(from_addr); // Does a user with this email already exist? sql = sql.Replace("$us", username.Replace("'", "''")); // We maybe found [email protected], so let's use him as the user instead of the btnet_service.exe user dr = btnet.DbUtil.get_datarow(sql); // We didn't find the user, so let's create him, using the email address as the username. if (dr == null) { bool use_domain_as_org_name = Util.get_setting("UseEmailDomainAsNewOrgNameWhenCreatingNewUser", "0") == "1"; btnet.User.copy_user( username, username, "", "", "", // first, last, signature 0, // salt Guid.NewGuid().ToString(), // random value for password, Util.get_setting("CreateUsersFromEmailTemplate", "[error - missing user template]"), use_domain_as_org_name); // now that we have created a user, try again dr = btnet.DbUtil.get_datarow(sql); } } else { // Use the btnet_service.exe user as the username sql = sql.Replace("$us", username.Replace("'", "''")); dr = btnet.DbUtil.get_datarow(sql); } return(dr); }