예제 #1
0
        public override global::System.Data.DataSet Clone()
        {
            MailTopic cln = ((MailTopic)(base.Clone()));

            cln.InitVars();
            cln.SchemaSerializationMode = this.SchemaSerializationMode;
            return(cln);
        }
예제 #2
0
        public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedDataSetSchema(global::System.Xml.Schema.XmlSchemaSet xs)
        {
            MailTopic ds = new MailTopic();

            global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
            global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
            global::System.Xml.Schema.XmlSchemaAny         any      = new global::System.Xml.Schema.XmlSchemaAny();
            any.Namespace = ds.Namespace;
            sequence.Items.Add(any);
            type.Particle = sequence;
            global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
            if (xs.Contains(dsSchema.TargetNamespace))
            {
                global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                try {
                    global::System.Xml.Schema.XmlSchema schema = null;
                    dsSchema.Write(s1);
                    for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                    {
                        schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                        s2.SetLength(0);
                        schema.Write(s2);
                        if ((s1.Length == s2.Length))
                        {
                            s1.Position = 0;
                            s2.Position = 0;
                            for (; ((s1.Position != s1.Length) &&
                                    (s1.ReadByte() == s2.ReadByte()));)
                            {
                                ;
                            }
                            if ((s1.Position == s1.Length))
                            {
                                return(type);
                            }
                        }
                    }
                }
                finally {
                    if ((s1 != null))
                    {
                        s1.Close();
                    }
                    if ((s2 != null))
                    {
                        s2.Close();
                    }
                }
            }
            xs.Add(dsSchema);
            return(type);
        }
예제 #3
0
        protected override void Execute(CodeActivityContext context)
        {
            string username = Email.Get(context);                //发送端账号
            string password = Password.Get(context);             //发送端密码(这个客户端重置后的密码)
            string server   = Server.Get(context);               //邮件服务器
            Int32  port     = Port.Get(context);                 //端口号
            string from     = From.Get(context);                 //发送者地址(一般与发送账号相同)
            string name     = Name.Get(context);                 //发送者名称

            string[] receivers_To  = Receivers_To.Get(context);  //收件人
            string[] receivers_Cc  = Receivers_Cc.Get(context);  //抄送
            string[] recervers_Bcc = Receivers_Bcc.Get(context); //密送
            string   mailTopic     = MailTopic.Get(context);     //邮件的主题
            string   mailBody      = MailBody.Get(context);      //发送的邮件正文
            //string[] attachFiles = AttachFiles.Get(context);    //附件列表
            MimeMessage transMsg = TransMailMessage.Get(context);

            try
            {
                List <string> attachments = Attachments ?? new List <string>();
                foreach (InArgument <string> file in Files)
                {
                    AddAttachments(attachments, file.Get(context));
                }
                foreach (string item in AttachmentsCollection.Get(context).EmptyIfNull())
                {
                    AddAttachments(attachments, item);
                }

                MailKit.Net.Smtp.SmtpClient client = new MailKit.Net.Smtp.SmtpClient();
                client.Connect(server, port, SecureConnection);
                client.Authenticate(username, password);

                var multipart = new Multipart("mixed");

                MimeMessage msg = new MimeMessage();
                if (name == null && from == null)
                {
                    msg.From.Add((new MailboxAddress(username)));
                }
                else if (name == null && from != null)
                {
                    msg.From.Add((new MailboxAddress(from)));
                }
                else if (name != null && from == null)
                {
                    msg.From.Add((new MailboxAddress(name, username)));
                }
                else
                {
                    msg.From.Add((new MailboxAddress(name, from)));
                }

                if (receivers_To != null)
                {
                    foreach (string receiver in receivers_To)
                    {
                        msg.To.Add((new MailboxAddress(receiver)));
                    }
                }
                if (receivers_Cc != null)
                {
                    foreach (string receiver in receivers_Cc)
                    {
                        msg.Cc.Add((new MailboxAddress(receiver)));
                    }
                }
                if (recervers_Bcc != null)
                {
                    foreach (string receiver in recervers_Bcc)
                    {
                        msg.Bcc.Add((new MailboxAddress(receiver)));
                    }
                }


                if (mailBody != null)
                {
                    if (!IsBodyHtml)
                    {
                        var plain = new TextPart(TextFormat.Plain)
                        {
                            Text = mailBody
                        };
                        multipart.Add(plain);
                    }
                    else
                    {
                        var Html = new TextPart(TextFormat.Html)
                        {
                            Text = mailBody
                        };
                        multipart.Add(Html);
                    }
                }
                else if (transMsg != null)
                {
                    if (!IsBodyHtml)
                    {
                        var plain = new TextPart(TextFormat.Plain)
                        {
                            Text = transMsg.TextBody
                        };
                        multipart.Add(plain);
                    }
                    else
                    {
                        var Html = new TextPart(TextFormat.Html)
                        {
                            Text = transMsg.HtmlBody
                        };
                        multipart.Add(Html);
                    }
                }
                else
                {
                    var plain = new TextPart(TextFormat.Plain)
                    {
                        Text = ""
                    };
                    multipart.Add(plain);
                }



                if (mailTopic != null)
                {
                    msg.Subject = mailTopic;
                }
                else if (transMsg != null)
                {
                    msg.Subject = transMsg.Subject;
                }

                msg.Priority = msgProperty;

                if (Files != null)
                {
                    foreach (var p in Files)
                    {
                        try
                        {
                            if (!string.IsNullOrEmpty(p.ToString()))
                            {
                                var attimg = new MimePart()
                                {
                                    Content                 = new MimeContent(File.OpenRead(p.ToString()), ContentEncoding.Default),
                                    ContentDisposition      = new ContentDisposition(ContentDisposition.Attachment),
                                    ContentTransferEncoding = ContentEncoding.Base64,
                                    FileName                = Path.GetFileName(p.ToString())
                                };
                                multipart.Add(attimg);
                            }
                        }
                        catch (FileNotFoundException ex)
                        {
                            SharedObject.Instance.Output(SharedObject.enOutputType.Error, "文件未找到,请检查有效路径", ex.Message);
                        }
                    }
                }
                if (transMsg != null)
                {
                    foreach (MimeEntity part in transMsg.Attachments)
                    {
                        multipart.Add(part);
                    }
                }


                msg.Body = multipart;
                try
                {
                    client.Send(msg);
                    Debug.WriteLine("发送成功");
                }
                catch (System.Net.Mail.SmtpException ex)
                {
                    Debug.WriteLine(ex.Message, "发送邮件出错");
                }
            }
            catch (Exception e)
            {
                SharedObject.Instance.Output(SharedObject.enOutputType.Error, "发送邮件失败", e.Message);
            }
        }
예제 #4
0
 public virtual int Update(MailTopic dataSet)
 {
     return(this.Adapter.Update(dataSet, "Tbl_MailTopic"));
 }
예제 #5
0
            public static global::System.Xml.Schema.XmlSchemaComplexType GetTypedTableSchema(global::System.Xml.Schema.XmlSchemaSet xs)
            {
                global::System.Xml.Schema.XmlSchemaComplexType type     = new global::System.Xml.Schema.XmlSchemaComplexType();
                global::System.Xml.Schema.XmlSchemaSequence    sequence = new global::System.Xml.Schema.XmlSchemaSequence();
                MailTopic ds = new MailTopic();

                global::System.Xml.Schema.XmlSchemaAny any1 = new global::System.Xml.Schema.XmlSchemaAny();
                any1.Namespace       = "http://www.w3.org/2001/XMLSchema";
                any1.MinOccurs       = new decimal(0);
                any1.MaxOccurs       = decimal.MaxValue;
                any1.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any1);
                global::System.Xml.Schema.XmlSchemaAny any2 = new global::System.Xml.Schema.XmlSchemaAny();
                any2.Namespace       = "urn:schemas-microsoft-com:xml-diffgram-v1";
                any2.MinOccurs       = new decimal(1);
                any2.ProcessContents = global::System.Xml.Schema.XmlSchemaContentProcessing.Lax;
                sequence.Items.Add(any2);
                global::System.Xml.Schema.XmlSchemaAttribute attribute1 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute1.Name       = "namespace";
                attribute1.FixedValue = ds.Namespace;
                type.Attributes.Add(attribute1);
                global::System.Xml.Schema.XmlSchemaAttribute attribute2 = new global::System.Xml.Schema.XmlSchemaAttribute();
                attribute2.Name       = "tableTypeName";
                attribute2.FixedValue = "Tbl_MailTopicDataTable";
                type.Attributes.Add(attribute2);
                type.Particle = sequence;
                global::System.Xml.Schema.XmlSchema dsSchema = ds.GetSchemaSerializable();
                if (xs.Contains(dsSchema.TargetNamespace))
                {
                    global::System.IO.MemoryStream s1 = new global::System.IO.MemoryStream();
                    global::System.IO.MemoryStream s2 = new global::System.IO.MemoryStream();
                    try {
                        global::System.Xml.Schema.XmlSchema schema = null;
                        dsSchema.Write(s1);
                        for (global::System.Collections.IEnumerator schemas = xs.Schemas(dsSchema.TargetNamespace).GetEnumerator(); schemas.MoveNext();)
                        {
                            schema = ((global::System.Xml.Schema.XmlSchema)(schemas.Current));
                            s2.SetLength(0);
                            schema.Write(s2);
                            if ((s1.Length == s2.Length))
                            {
                                s1.Position = 0;
                                s2.Position = 0;
                                for (; ((s1.Position != s1.Length) &&
                                        (s1.ReadByte() == s2.ReadByte()));)
                                {
                                    ;
                                }
                                if ((s1.Position == s1.Length))
                                {
                                    return(type);
                                }
                            }
                        }
                    }
                    finally {
                        if ((s1 != null))
                        {
                            s1.Close();
                        }
                        if ((s2 != null))
                        {
                            s2.Close();
                        }
                    }
                }
                xs.Add(dsSchema);
                return(type);
            }