2013-07-21 186 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