• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ASObject类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ASObject的典型用法代码示例。如果您正苦于以下问题:C# ASObject类的具体用法?C# ASObject怎么用?C# ASObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ASObject类属于命名空间,在下文中一共展示了ASObject类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: WriteData

        public void WriteData(AMFWriter writer, object data)
        {
            NameObjectCollectionBase collection = data as NameObjectCollectionBase;
            object[] attributes = collection.GetType().GetCustomAttributes(typeof(DefaultMemberAttribute), false);
            if (attributes != null  && attributes.Length > 0)
            {
                DefaultMemberAttribute defaultMemberAttribute = attributes[0] as DefaultMemberAttribute;
                PropertyInfo pi = collection.GetType().GetProperty(defaultMemberAttribute.MemberName, new Type[] { typeof(string) });
                if (pi != null)
                {
                    ASObject aso = new ASObject();
                    for (int i = 0; i < collection.Keys.Count; i++)
                    {
                        string key = collection.Keys[i];
                        object value = pi.GetValue(collection, new object[]{ key });
                        aso.Add(key, value);
                    }
                    writer.WriteByte(AMF3TypeCode.Object);
                    writer.WriteAMF3Object(aso);
                    return;
                }
            }

            //We could not access an indexer so write out as it is.
            writer.WriteByte(AMF3TypeCode.Object);
            writer.WriteAMF3Object(data);
        }
开发者ID:apakian,项目名称:fluorinefx,代码行数:27,代码来源:AMF3NameObjectCollectionWriter.cs


示例2: onMailAudited

        private void onMailAudited(string sender, ime.notification.NotifyMessage e, NotificationCenter.Stage stage)
        {
            if (stage == NotificationCenter.Stage.Receiving)
            {
                Application.Current.Dispatcher.Invoke((System.Action)delegate
                {
                    if (!DBWorker.IsDBCreated())
                        return;
                    XElement xml = e.Body as XElement;
                    if (xml == null)
                        return;
                    XElement msgXml = xml.Element("message");
                    if (msgXml == null)
                        return;

                    ASObject mail = new ASObject();
                    mail["uuid"] = msgXml.AttributeValue("uuid");
                    mail["folder"] = "SENDED";
                    MailWorker.instance.updateMailRecord(mail, new string[] { "folder" });
                    MailWorker.instance.dispatchMailEvent(MailWorker.Event.Reset, null, null);
                    Application.Current.Dispatcher.Invoke((System.Action)delegate
                    {
                        e.Show();
                    }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
                }, System.Windows.Threading.DispatcherPriority.ApplicationIdle);
            }
        }
开发者ID:nbhopson,项目名称:QMail,代码行数:27,代码来源:Plugin.cs


示例3: WriteData

        public void WriteData(AMFWriter writer, object data)
        {
            var collection = data as NameObjectCollectionBase;
            var attributes = collection.GetType().GetCustomAttributes(typeof(DefaultMemberAttribute), false);
            if (attributes != null  && attributes.Length > 0)
            {
                var defaultMemberAttribute = attributes[0] as DefaultMemberAttribute;
                var pi = collection.GetType().GetProperty(defaultMemberAttribute.MemberName, new[] { typeof(string) });
                if (pi != null)
                {
                    var aso = new ASObject();
                    for (var i = 0; i < collection.Keys.Count; i++)
                    {
                        var key = collection.Keys[i];
                        var value = pi.GetValue(collection, new object[]{ key });
                        aso.Add(key, value);
                    }
                    writer.WriteASO(ObjectEncoding.AMF0, aso);
                    return;
                }
            }

            //We could not access an indexer so write out as it is.
            writer.WriteObject(ObjectEncoding.AMF0, data);
        }
开发者ID:mstaessen,项目名称:fluorinefx,代码行数:25,代码来源:AMF0NameObjectCollectionWriter.cs


示例4: HandleResult

        /// <summary>
        /// This method supports the Fluorine infrastructure and is not intended to be used directly from your code.
        /// </summary>
        /// <param name="invocationManager"></param>
        /// <param name="memberInfo"></param>
        /// <param name="obj"></param>
        /// <param name="arguments"></param>
        /// <param name="result"></param>
        public void HandleResult(IInvocationManager invocationManager, MemberInfo memberInfo, object obj, object[] arguments, object result)
		{
			if( result is DataSet )
			{
				DataSet dataSet = result as DataSet;
				ASObject asoResult = new ASObject(_remoteClass);

#if !(NET_1_1)
                foreach (KeyValuePair<object, object> entry in invocationManager.Properties)
#else
				foreach(DictionaryEntry entry in invocationManager.Properties)
#endif
				{
					if( entry.Key is DataTable )
					{
						DataTable dataTable = entry.Key as DataTable;
						if( dataSet.Tables.IndexOf(dataTable) != -1 )
						{
							if( !dataTable.ExtendedProperties.ContainsKey("alias") )
								asoResult[dataTable.TableName] = entry.Value;
							else
								asoResult[ dataTable.ExtendedProperties["alias"] as string ] = entry.Value;
						}
					}
				}
				invocationManager.Result = asoResult;
			}
		}
开发者ID:RanadeepPolavarapu,项目名称:LoLNotes,代码行数:36,代码来源:DataSetTypeAttribute.cs


示例5: NetStatusEventArgs

		internal NetStatusEventArgs(string message) {
			_info = new ASObject();
			_info["level"] = "error";
			_info["code"] = StatusASO.NC_CALL_FAILED;
			//_info["description"] = message;
			_info["details"] = message;
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:7,代码来源:NetStatusEventArgs.cs


示例6: getCapabilities

		/// <summary>
		/// Returns the capabilities of the ServiceBrowser as currently implemented. 
		/// Universal Remoting enabled projects may choose to implement all or some of the capabilities of the front-end.
		/// </summary>
		/// <returns>
		/// An array of objects. Each object should be in the format {name:String, version:Number, data:*}. 
		/// </returns>
		public ASObject getCapabilities()
		{
			string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
			ASObject result = new ASObject();
			// authentication: This Remoting implementation supports AMF0/AMF3 authentication
			ASObject asoAuthentication = new ASObject();
			asoAuthentication["name"] = "authentication";
			asoAuthentication["version"] = "FormsAuthentication";
			asoAuthentication["data"] = "true";
			result["authentication"] = asoAuthentication;
			// secure: The user of the service browser must authenticate him/herself with 
			// the unlock method before accessing it. 
			// The roles of all the methods except verifyLogin and getCapabilities should be set 
			// to admin.
			//ASObject secure = new ASObject();
			// codegen: This service browser supports code generation
			ASObject asoCodegen = new ASObject();
			asoCodegen["name"] = "codegen";
			asoCodegen["version"] = version;
			asoCodegen["data"] = CodeGeneratorService.GetCodeTemplates();//.ToArray(typeof(object)) as object[];
			result["codegen"] = asoCodegen;
			result["version"] = version;

			// codesave: This service browser supports code saving. 
			// data in this case may contain the enabled key. 
			// If enabled is set to false, indicates that the remote class has the remote code 
			// saving capability, but it is disabled because of a lack of permissions in the target directory.
			// if data is null, assume enabled is true.
			//ASObject codesave = new ASObject();

			return result;
		}
开发者ID:apakian,项目名称:fluorinefx,代码行数:39,代码来源:FluorineServiceBrowser.cs


示例7: GetInformation

		public ASObject GetInformation()
		{
			ASObject info = new ASObject();
			info["name"] = "Fluorine .NET Flash Remoting Gateway";
			info["version"] = Assembly.GetExecutingAssembly().GetName().Version.ToString();
			return info;
		}
开发者ID:apakian,项目名称:fluorinefx,代码行数:7,代码来源:DiagnosticService.cs


示例8: ToRequestObject

 public FluorineFx.ASObject ToRequestObject()
 {
     FluorineFx.ASObject retVal = new ASObject();
     retVal.Add("sigTime", _sigTime);
     retVal.Add("token", _token);
     retVal.Add("flashRevision", _flashRevision);
     retVal.Add("userId", _userId);
     return retVal;
 }
开发者ID:replic8tor,项目名称:Rustler,代码行数:9,代码来源:BasicSessionInfo.cs


示例9: ReadData

		public object ReadData(AMFReader reader, ClassDefinition classDefinition) {
			ASObject aso = new ASObject(_typeIdentifier);
			reader.AddAMF3ObjectReference(aso);
			string key = reader.ReadAMF3String();
			aso.TypeName = _typeIdentifier;
			while (key != string.Empty) {
				object value = reader.ReadAMF3Data();
				aso.Add(key, value);
				key = reader.ReadAMF3String();
			}
			return aso;
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:12,代码来源:AMF3TypedASObjectReader.cs


示例10: Invoke

		public override void Invoke(AMFContext context) {
			MessageBroker messageBroker = _endpoint.GetMessageBroker();
			try {
				AMFHeader amfHeader = context.AMFMessage.GetHeader(AMFHeader.CredentialsHeader);
				if (amfHeader != null && amfHeader.Content != null) {
					string userId = ((ASObject)amfHeader.Content)["userid"] as string;
					string password = ((ASObject)amfHeader.Content)["password"] as string;
					//Clear credentials header, further requests will not send the credentials
					ASObject asoObject = new ASObject();
					asoObject["name"] = AMFHeader.CredentialsHeader;
					asoObject["mustUnderstand"] = false;
					asoObject["data"] = null;//clear
					AMFHeader header = new AMFHeader(AMFHeader.RequestPersistentHeader, true, asoObject);
					context.MessageOutput.AddHeader(header);
					IPrincipal principal = _endpoint.GetMessageBroker().LoginManager.Login(userId, amfHeader.Content as IDictionary);
					string key = EncryptCredentials(_endpoint, principal, userId, password);
					ASObject asoObjectCredentialsId = new ASObject();
					asoObjectCredentialsId["name"] = AMFHeader.CredentialsIdHeader;
					asoObjectCredentialsId["mustUnderstand"] = false;
					asoObjectCredentialsId["data"] = key;//set
					AMFHeader headerCredentialsId = new AMFHeader(AMFHeader.RequestPersistentHeader, true, asoObjectCredentialsId);
					context.MessageOutput.AddHeader(headerCredentialsId);
				} else {
					amfHeader = context.AMFMessage.GetHeader(AMFHeader.CredentialsIdHeader);
					if (amfHeader != null) {
						string key = amfHeader.Content as string;
						if (key != null)
							_endpoint.GetMessageBroker().LoginManager.RestorePrincipal(key);
					} else {
						_endpoint.GetMessageBroker().LoginManager.RestorePrincipal();
					}
				}
			} catch (UnauthorizedAccessException exception) {
				for (int i = 0; i < context.AMFMessage.BodyCount; i++) {
					AMFBody amfBody = context.AMFMessage.GetBodyAt(i);
					ErrorResponseBody errorResponseBody = new ErrorResponseBody(amfBody, exception);
					context.MessageOutput.AddBody(errorResponseBody);
				}
			} catch (Exception exception) {
				if (log != null && log.IsErrorEnabled)
					log.Error(exception.Message, exception);
				for (int i = 0; i < context.AMFMessage.BodyCount; i++) {
					AMFBody amfBody = context.AMFMessage.GetBodyAt(i);
					ErrorResponseBody errorResponseBody = new ErrorResponseBody(amfBody, exception);
					context.MessageOutput.AddBody(errorResponseBody);
				}
			}
		}
开发者ID:GodLesZ,项目名称:svn-dump,代码行数:48,代码来源:AuthenticationFilter.cs


示例11: ParseQuery

 public object ParseQuery(string url, string sql)
 {
     ASObject aso = new ASObject();
     try
     {
         FluorineFx.ServiceBrowser.Sql.ISqlScript sqlScript = FluorineFx.ServiceBrowser.Sql.SqlParserService.Parse(sql);
         aso["message"] = "Sql statement was parsed and found to be a valid";
     }
     catch (antlr.RecognitionException ex)
     {
         aso["message"] = "The specified SQL statement failed to be parsed: " + ex.ToString();
     }
     catch (Exception ex)
     {
         aso["message"] = "The specified SQL statement failed to be parsed: " + ex.Message;
     }
     return aso;
 }
开发者ID:DarkActive,项目名称:daFluorineFx,代码行数:18,代码来源:SqlService.cs


示例12: GGChatUser

 public GGChatUser(ASObject user)
 {
     try
     {
         if( user.ContainsKey("banned") )
             _banned = bool.Parse(user["banned"].ToString());
         if (user.ContainsKey("color"))
             _color = (string)user["color"];
         if (user.ContainsKey("id"))
             _id = int.Parse(user["id"].ToString());
         if (user.ContainsKey("level"))
             _level = int.Parse(user["level"].ToString());
         if (user.ContainsKey("name"))
             _name = (string)user["name"];
         if (user.ContainsKey("sex"))
             _gender = int.Parse(user["sex"].ToString());
     }
     catch { }
 }
开发者ID:ByteSempai,项目名称:Ubiquitous,代码行数:19,代码来源:Goodgame.cs


示例13: AddSubscriber

        public MessageClient AddSubscriber(string clientId, string endpointId, Subtopic subtopic, Selector selector)
		{
			lock(_objLock)
			{
                if (subtopic != null)
                {
                    MessagingAdapter messagingAdapter = _messageDestination.ServiceAdapter as MessagingAdapter;
                    if (messagingAdapter != null)
                    {
                        if (!messagingAdapter.AllowSubscribe(subtopic))
                        {
                            ASObject aso = new ASObject();
                            aso["subtopic"] = subtopic.Value;
                            throw new MessageException(aso);
                        }
                    }
                }
                if (!_subscribers.Contains(clientId))
                {
                    //Set in RtmpService
                    MessageClient messageClient = new MessageClient(clientId, _messageDestination, endpointId);
                    messageClient.Subtopic = subtopic;
                    messageClient.Selector = selector;
                    messageClient.AddSubscription(selector, subtopic);
                    AddSubscriber(messageClient);
                    messageClient.NotifyCreatedListeners();
                    return messageClient;
                }
                else
                {
                    MessageClient messageClient = _subscribers[clientId] as MessageClient;
                    IClient client = FluorineContext.Current.Client;
                    if (client != null && !client.Id.Equals(messageClient.Client.Id))
                    {
                        throw new MessageException("Duplicate subscriptions from multiple Flex Clients");
                    }
                    //Reset the endpoint push state for the subscription to make sure its current because a resubscribe could be arriving over a new endpoint or a new session.
                    messageClient.ResetEndpoint(endpointId);
                    return messageClient;
                }
			}
		}
开发者ID:Nicholi,项目名称:fluorinefx-mod,代码行数:42,代码来源:SubscriptionManager.cs


示例14: SyncWorker

        protected SyncWorker()
        {
            sql.Clear();
            sql.Append("select * from ML_Mail where [email protected]_synced or [email protected]_synced1");

            using (DataSet ds = new DataSet())
            {
                try
                {
                    using (SQLiteCommand cmd = new SQLiteCommand(sql.ToString(), DBWorker.GetConnection()))
                    {
                        cmd.Parameters.AddWithValue("@is_synced", 1);
                        cmd.Parameters.AddWithValue("@is_synced1", 0);
                        using (SQLiteDataAdapter q = new SQLiteDataAdapter(cmd))
                        {
                            q.Fill(ds);
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.Write(ex.StackTrace);
                }
                if (ds.Tables.Count > 0)
                {
                    using (DataTable dt = ds.Tables[0])
                    {
                        foreach (DataRow row in dt.Rows)
                        {
                            ASObject mail = new ASObject();
                            foreach (DataColumn column in dt.Columns)
                            {
                                mail[column.ColumnName] = row[column];
                            }
                            mailList.Add(mail);
                        }
                    }
                }
            }
        }
开发者ID:nbhopson,项目名称:QMail,代码行数:40,代码来源:SyncWorker.cs


示例15: SubmitQuery

        public object SubmitQuery(string url, string sql)
        {
            Hashtable result = new Hashtable();
            try
            {
                DomainUrl domainUrl = new DomainUrl(url);
                Driver driver = DriverFactory.GetDriver(domainUrl);
                using (IDbConnection dbConnection = driver.OpenConnection())
                {
                    IDbCommand command = driver.GetDbCommand(sql, dbConnection);
                    IDbDataAdapter adapter = driver.GetDbDataAdapter();
                    adapter.SelectCommand = command;
                    DataSet dataSet = new DataSet();
                    adapter.Fill(dataSet);

                    ASObject asoResult = new ASObject();
                    DataTable dataTable = dataSet.Tables[0];
                    ArrayList rows = new ArrayList(dataTable.Rows.Count);
                    for (int i = 0; i < dataTable.Rows.Count; i++)
                    {
                        DataRow dataRow = dataTable.Rows[i];
                        ASObject asoRow = new ASObject();
                        for (int j = 0; j < dataTable.Columns.Count; j++)
                        {
                            DataColumn column = dataTable.Columns[j];
                            asoRow.Add(column.ColumnName, dataRow[column]);
                        }
                        rows.Add(asoRow);
                    }
                    result["result"] = rows;
                }
            }
            catch (Exception ex)
            {
                result["message"] = ex.Message;
            }
            return result;
        }
开发者ID:DarkActive,项目名称:daFluorineFx,代码行数:38,代码来源:SqlService.cs


示例16: parseMIMEContent

        private void parseMIMEContent(Mail_Message m, string uid, string dir, ASObject record)
        {
            XmlDocument doc = new XmlDocument();
            XmlElement xml = doc.CreateElement("message");
            doc.AppendChild(xml);

            StringBuilder attachments = new StringBuilder();
            MIME_Entity[] entities = m.GetAllEntities(true);

            Map<string, string> content_id_file = new Map<string, string>();
            StringBuilder textHtml = new StringBuilder();
            textHtml.Append(@"<html><head><meta http-equiv=""content-type"" content=""text/html; charset=utf-8""></head><body>");
            bool hasText = false;

            foreach (MIME_Entity e in entities)
            {
                try
                {
                    if (e.Body.MediaType.ToLower() == MIME_MediaTypes.Text.html)
                        continue;
                    else if (e.Body.MediaType.ToLower() == MIME_MediaTypes.Text.plain)
                        continue;
                    else if (e.Body is MIME_b_SinglepartBase)
                    {
                        MIME_b_SinglepartBase p = (MIME_b_SinglepartBase)e.Body;
                        Stream data = p.GetDataStream();
                        string fPath = "";
                        string fileName = e.ContentType.Param_Name;
                        if (fileName == null)
                            fileName = Guid.NewGuid().ToString();
                        else
                            attachments.Append(fileName).Append(";");
                        fileName = fileName.Replace(' ', '_');
                        fPath = System.IO.Path.Combine(dir, fileName);
                        using (FileStream afs = File.Create(fPath))
                        {
                            Net_Utils.StreamCopy(data, afs, 4096);
                        }
                        data.Close();

                        string contentId = e.ContentID;
                        if (!String.IsNullOrEmpty(contentId))
                        {
                            contentId = contentId.Trim();
                            if (contentId.StartsWith("<"))
                                contentId = contentId.Substring(1);
                            if (contentId.EndsWith(">"))
                                contentId = contentId.Substring(0, contentId.Length - 1);
                            content_id_file.Add(contentId, fileName);
                        }

                        XmlElement part = doc.CreateElement("PART");
                        part.SetAttribute("type", "file");
                        part.SetAttribute("content-id", contentId);
                        part.SetAttribute("filename", fileName);
                        part.SetAttribute("description", e.ContentDescription);
                        if (e.ContentType != null)
                            part.SetAttribute("content-type", e.ContentType.ToString());
                        xml.AppendChild(part);
                    }
                }
                catch (Exception)
                {
                }
            }
            foreach (MIME_Entity e in entities)
            {
                try
                {
                    if (e.Body.MediaType.ToLower() == MIME_MediaTypes.Text.html)
                    {
                        string html = ((MIME_b_Text)e.Body).Text;

                        //处理html中的内嵌图片
                        if (content_id_file.Count > 0)
                        {
                            foreach (string key in content_id_file.Keys)
                            {
                                html = html.Replace("cid:" + key, content_id_file[key]);
                            }
                        }

                        XmlElement part = doc.CreateElement("PART");
                        part.SetAttribute("type", "html");
                        part.AppendChild(doc.CreateCDataSection(html));
                        xml.AppendChild(part);

                        string charset = "GBK";
                        if (e.ContentType != null && e.ContentType.Param_Charset != null)
                            charset = e.ContentType.Param_Charset;
                        else if (m.ContentType != null && m.ContentType.Param_Charset != null)
                            charset = m.ContentType.Param_Charset;

                        string html_charset = getHtmlEncoding(html);
                        if (html_charset == null)
                        {
                            int index = html.IndexOf("<head>", StringComparison.CurrentCultureIgnoreCase);
                            if (index != -1)
                            {
                                StringBuilder sb = new StringBuilder();
//.........这里部分代码省略.........
开发者ID:nbhopson,项目名称:QMail,代码行数:101,代码来源:MailWorker.cs


示例17: updateMailRecord

        /// <summary>
        /// 更新邮件记录
        /// </summary>
        /// <param name="mail"></param>
        /// <param name="updateFields"></param>
        public void updateMailRecord(ASObject mail, string[] updateFields)
        {
            if (mail == null || updateFields == null || updateFields.Length == 0)
                return;
            string sql = @"update ML_Mail set ";
            StringBuilder sb = new StringBuilder();
            sb.Append(sql);
            foreach (string field in updateFields)
            {
                sb.Append(field).Append("[email protected]").Append(field).Append(",");
            }
            if (sb.ToString().LastIndexOf(",") != -1)
                sb.Remove(sb.ToString().LastIndexOf(","), 1);
            if(mail.ContainsKey("id"))
                sb.Append(" where [email protected]");
            else
                sb.Append(" where [email protected]");

            SQLiteCommand cmd = null;
            try
            {
                cmd = new SQLiteCommand(sb.ToString(), DBWorker.GetConnection());
                if (mail.ContainsKey("id"))
                    cmd.Parameters.AddWithValue("@id", mail["id"]);
                else
                    cmd.Parameters.AddWithValue("@uuid", mail["uuid"]);
                foreach (string field in updateFields)
                {
                    cmd.Parameters.AddWithValue("@" + field, mail[field]);
                }

                cmd.ExecuteNonQuery();

                cmd.Dispose();
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Write(ex.StackTrace);
            }
            finally
            {
                if (cmd != null)
                {
                    cmd.Dispose();
                }
            }
        }
开发者ID:nbhopson,项目名称:QMail,代码行数:52,代码来源:MailWorker.cs


示例18: updateMail

        /// <summary>
        /// 保存邮件并同步邮件到服务器,采用异步方式,但必须保证执行顺序
        /// </summary>
        /// <param name="mail">邮件记录</param>
        /// <param name="fields">保存或同步的字段</param>
        public void updateMail(ASObject mail, string[] updateFields)
        {
            // 保存邮件到本地并同步到服务器
            try
            {
                if (mail == null || updateFields == null)
                    return;
                updateMailRecord(mail, updateFields);

                syncUserMail(mail);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
            }
        }
开发者ID:nbhopson,项目名称:QMail,代码行数:21,代码来源:MailWorker.cs


示例19: syncUserMail

 /// <summary>
 /// 与服务器同步邮件信息
 /// </summary>
 /// <param name="record"></param>
 public void syncUserMail(ASObject record)
 {
     if (record == null)
         return;
     AsyncOption option = new AsyncOption("MailManager.syncUserMail");
     option.asyncData = record;
     option.showWaitingBox = false;
     Remoting.call("MailManager.syncUserMail", new object[] { record }, this, option);
 }
开发者ID:nbhopson,项目名称:QMail,代码行数:13,代码来源:MailWorker.cs


示例20: sendReceiptMail

        /// <summary>
        /// 发送阅读回折邮件
        /// </summary>
        /// <param name="sHtmlText">邮件内容</param>
        /// <param name="from">发送人</param>
        /// <param name="to">接收人</param>
        public void sendReceiptMail(string sHtmlText, string subject, ASObject from, string[] to)
        {
            using (MemoryStreamEx stream = new MemoryStreamEx(32000))
            {
                Mail_Message m = new Mail_Message();
                m.MimeVersion = "1.0";
                m.Date = DateTime.Now;
                m.MessageID = MIME_Utils.CreateMessageID();

                m.Subject = subject;
                StringBuilder sb = new StringBuilder();
                foreach (string p in to)
                {
                    if (sb.Length > 0)
                        sb.Append(",");
                    sb.Append(p);
                }
                m.To = Mail_t_AddressList.Parse(sb.ToString());

                //--- multipart/alternative -----------------------------------------------------------------------------------------
                MIME_h_ContentType contentType_multipartAlternative = new MIME_h_ContentType(MIME_MediaTypes.Multipart.alternative);
                contentType_multipartAlternative.Param_Boundary = Guid.NewGuid().ToString().Replace('-', '.');
                MIME_b_MultipartAlternative multipartAlternative = new MIME_b_MultipartAlternative(contentType_multipartAlternative);
                m.Body = multipartAlternative;

                //--- text/plain ----------------------------------------------------------------------------------------------------
                MIME_Entity entity_text_plain = new MIME_Entity();
                MIME_b_Text text_plain = new MIME_b_Text(MIME_MediaTypes.Text.plain);
                entity_text_plain.Body = text_plain;
                text_plain.SetText(MIME_TransferEncodings.QuotedPrintable, Encoding.UTF8, sHtmlText);
                multipartAlternative.BodyParts.Add(entity_text_plain);

                //--- text/html ------------------------------------------------------------------------------------------------------
                MIME_Entity entity_text_html = new MIME_Entity();
                MIME_b_Text text_html = new MIME_b_Text(MIME_MediaTypes.Text.html);
                entity_text_html.Body = text_html;
                text_html.SetText(MIME_TransferEncodings.QuotedPrintable, Encoding.UTF8, sHtmlText);
                multipartAlternative.BodyParts.Add(entity_text_html);

                MIME_Encoding_EncodedWord headerwordEncoder = new MIME_Encoding_EncodedWord(MIME_EncodedWordEncoding.Q, Encoding.UTF8);
                m.ToStream(stream, headerwordEncoder, Encoding.UTF8);
                stream.Position = 0;

                SMTP_Client.QuickSendSmartHost(null, from.getString("send_address", "stmp.sina.com"), from.getInt("send_port", 25),
                    from.getBoolean("is_send_ssl", false), from.getString("account"), PassUtil.Decrypt(from.getString("password")),
                    from.getString("account"), to, stream);
            }
        }
开发者ID:nbhopson,项目名称:QMail,代码行数:54,代码来源:MailWorker.cs



注:本文中的ASObject类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ASPxComboBox类代码示例发布时间:2022-05-24
下一篇:
C# ASN1类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap