2013-07-21 156 views
-2

我的项目是在接收到消息后在Visual Studio中向Outlook Body发送字段,以便在用户可以修改Outlook中的文本字段中发送的数据并将更新数据发送到将被保存在可以将数据从Outlook更新到数据库的数据库中?从Outlook获取数据到数据库

+0

从outlook读取数据是可能的,但是您的问题还不够清楚,什么是outlook body?!你的意思是电子邮件正文或什么? – VahidNaderi

+1

你当然可以,但是你能证明你到目前为止已经尝试了什么,哪些不起作用? – JMK

+0

VahidND是的,我的意思是电子邮件正文 – user2586714

回答

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 
+0

谢谢,但我需要阅读BodyItem不是文件项目,并为每个文本框我将它保存n表上的数据库雇员(名称,ImprovedAction,挑战,dateChallenge,评论) – user2586714