2015-01-14 91 views
-1

我有以下問題。我使用MSword郵件合併發送電子郵件。我經常發送100-500封電子郵件(不是垃圾郵件,單數請求)。我將我的電子郵件地址保存在一張MSexcel表單中。許多電子郵件地址被破壞,大多數回覆都是消極的。許多電子郵件回覆是在發送電子郵件的前30分鐘內發出的。收到回覆後,我需要在Excel列表中標記回覆。這個過程可能非常耗時。因此,這個問題。現在,這個問題。Outlook/Excel集成?

有沒有辦法使我的電腦檢查我的電子郵件的主題行是否爲指定的字符串,如果它包含該字符串,那麼它會從該電子郵件中複製電子郵件地址,無論是在電子郵件的正文中,還是在發件人字段中,然後移至指定的Excel表格,在Excel表格中搜索電子郵件地址,然後在Excel表格中標記電子郵件地址。

非常高興任何人都可以指出我在正確的方向。我絕對沒有編程經驗。我一生都在使用電腦,但主要是發送和接收電子郵件,或瀏覽互聯網。

+0

這個是不是一個真正的「上主題」這個網站的問題與數據庫管理無關。但是,我猜你有一臺Exchange服務器(因爲你使用的是Outlook),所以一種方法是使用Exchange Web服務讀取電子郵件並寫入Excel文件的C#.Net應用程序 –

回答

0

您可以從Excel中直接使用,這是你想要的東西有點大材小用,但如果你不需要他們,你可以刪除字段:

'********************************************************************************************* 
' All code is supplied under the Creative Commons License (CC). Code samples provided by 
' Wilde XL Solutions are strictly for non-commerical use only and provided for the purpose 
' learning and study. If you would like to seek permission to use this code in any way other 
' than specified in this license agreement, please email [email protected] 
' 
' A copy of the general creative commons (CC) license can be found at: 
' http://tinyurl.com/WXLSCCinfo 
'********************************************************************************************* 

Sub getMail() 

     ' This sub is designed to be used with a blank worksheet. It will create the header 
     ' fields as required, and continue to populate the email data below the relevant header. 

     ' Declare required variables 
     '------------------------------------------------------------- 
    Dim olApp As Object 
    Dim olFolder As Object 
    Dim olMailItem As Object 

    Dim strTo As String 
    Dim strFrom As String 
    Dim dateSent As Variant 
    Dim dateReceived As Variant 
    Dim strSubject As String 
    Dim strBody As String 

    Dim loopControl As Variant 
    Dim mailCount As Long 
    Dim totalItems As Long 
     '------------------------------------------------------------- 

     'Turn off screen updating 
    Application.ScreenUpdating = False 

     'Setup headers for information 
    Range("A1:F1").Value = Array("To", "From", "Subject", "Body", "Sent (from Sender)", "Received (by Recipient)") 

     'Format columns E and F to 
    Columns("E:F").EntireColumn.NumberFormat = "DD/MM/YYYY HH:MM:SS" 

     'Create instance of Outlook 
    Set olApp = CreateObject("Outlook.Application") 

     'Select folder to extract mail from 
    Set olFolder = olApp.GetNamespace("MAPI").PickFolder 

     'Get count of mail items 
    totalItems = olFolder.items.Count 
    mailCount = 0 

     'Loop through mail items in folder 
    For Each loopControl In olFolder.items 

      'If loopControl is a mail item then continue 
     If TypeName(loopControl) = "MailItem" Then 

       'Increase mailCount 
      mailCount = mailCount + 1 

       'Inform user of item count in status bar 
      Application.StatusBar = "Reading email no. " & mailCount & " of " & totalItems 

       'Get mail item 
      Set olMailItem = loopControl 

       'Get Details 
      With olMailItem 
       strTo = .To 
        'If strTo begins with "=" then place an apostrophe in front to denote text format 
       If Left(strTo, 1) = "=" Then strTo = "'" & strTo 
       strFrom = .Sender 
        'If sender displays name only, show name followed by email address e.g.(Bloggs, Joe <[email protected]>) 
       If InStr(1, strFrom, "@") < 1 Then strFrom = strFrom & " - < " & .SenderEmailAddress & " >" 
       dateSent = .SentOn 
       dateReceived = .ReceivedTime 
       strSubject = .Subject 
       strBody = .Body 
      End With 

       'Place information into spreadsheet 
       'import information starting from last blank row in column A 
      With Range("A" & Rows.Count).End(xlUp).Offset(0, 0) 
       .Value = strTo 
       .Offset(1, 1).Value = strFrom 
       .Offset(2, 2).Value = strSubject 

        'Check for previous replies by looking for "From:" in the body text 
        'Check for the word "From:" 
       If InStr(0, strBody, "From:") > 0 Then 
         'If exists, copy start of email body, up to the position of "From:" 
        .Offset(1, 1).Value = Mid(strBody, 1, InStr(1, strBody, "From:") - 1) 
       Else 
         'If doesn't exist, copy entire mail body 
        .Offset(3, 3).Value = strBody 
       End If 

       .Offset(4, 4).Value = dateSent 
       .Offset(5, 5).Value = dateReceived 

      End With 

       'Release item from memory 
      Set olMailItem = Nothing 

     End If 

      'Next Item 
    Next loopControl 

     'Release items from memory 
    Set olFolder = Nothing 
    Set olApp = Nothing 

     'Resume screen updating 
    Application.ScreenUpdating = True 

     'reset status bar 
    Application.StatusBar = False 

     'Inform user that code has finished 
    MsgBox mailCount & " messages copied successfully.", vbInformation, "Complete" 

End Sub 
+0

不知道我在哪裏會運行這個腳本。我會在Excel中運行這個腳本嗎? –

+0

是的,將它放在一個Excel工作簿中的標準模塊中並從那裏運行它,它自己完成剩下的工作。 –

+0

很酷。好吧,我得到了可視化的基本編輯器,並打開了模塊。現在,我需要弄清楚這個過程中的下一個步驟。順便說一句,非常感謝你的幫助。 –