从Outlook获取数据到数据库

时间:2013-07-21 13:59:28

标签: visual-studio-2010 outlook

我的项目是在收到消息之后在Visual Studio中将字段发送到正文中的字段中,用户可以修改Outlook上文本字段中发送的数据并发送更新数据,它将保存在数据库中可以将数据从outlook更新到数据库吗?

1 个答案:

答案 0 :(得分:0)

我已经构建了这样的解决方案,我每天都使用它来阅读和归档邮件,作为我日常工作流程的一部分。但正如其他人暗示的那样,你需要具体说明你需要帮助的内容。

        If (TypeOf olItem Is Outlook.MailItem) Then
            Dim olMailItem As Outlook.MailItem = TryCast(olItem, Outlook.MailItem)

            If olMailItem.Permission = Outlook.OlPermission.olUnrestricted Then
                strBody = olMailItem.HTMLBody                   'file:///C:/AttSave/header.png
            Else
                strBody = "Rights Protected fix if I'm not in debugger"
            End If

            For Each olAttach In olMailItem.Attachments
                If olAttach.Type <> Outlook.OlAttachmentType.olOLE Then
                    olAttach.SaveAsFile("c:\AttSave\" & olAttach.FileName)
                    'strBody = strBody.Replace("cid:header", "file:///C:/AttSave/header.png")
                    strCID = olAttach.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x3712001E")
                    If strCID <> "" Then
                        strBody = strBody.Replace("cid:" & strCID, "file:///C:/AttSave/" & System.Web.HttpUtility.UrlEncode(olAttach.FileName))
                    End If
                    lst_Attach.Items.Add(olAttach.FileName)
                Else
                    MsgBox("open this one via outlook")
                End If

            Next
            Me.webBody.DocumentText = strBody
            Me.txtSubject.Text = olMailItem.Subject
            If olMailItem.Importance = Outlook.OlImportance.olImportanceHigh Then
                Me.txtSubject.ForeColor = Color.Red
            Else
                Me.txtSubject.ForeColor = Color.White
            End If

            'Dim palSender As Microsoft.Office.Interop.Outlook.AddressEntry
            'palSender = mailItem.Sender
            Me.txtSentDate.Text = olMailItem.SentOn
            'Me.txtTo.Text = olMailItem.To
            olSenderA = olMailItem.Sender
            If IsNothing(olSenderA) = False Then

                'Dim olConItem As Outlook.ContactItem

                'olConItem = olSenderA.GetContact()
                'If Not IsNothing(olConItem) Then
                '    If olConItem.HasPicture = True Then
                '        Stop
                '    End If
                'End If


                Pa = olSenderA.PropertyAccessor
                'Debug.Print(olRe.Name & "stp= " & Pa.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x39FE001E"))
                Try
                    Me.txtFrom.Text = Me.txtFrom.Text & olSenderA.Name & " (" & Pa.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x39FE001E") & ")"
                Catch ex As System.Runtime.InteropServices.COMException
                    'Stop
                    Me.txtFrom.Text = olMailItem.SenderName & " (" & olMailItem.SenderEmailAddress & ")"
                Catch ex As Exception
                    Stop
                End Try