2013-11-15 3 views
0

Outlook에서 선택한 메일을 찾아서 복사하려면 VBA가 필요합니다. 그 라인에는VBA Outlook 본문 검색

메일 박스가 포함되어 있습니다 : ???????????????

그 라인에있는 문자의 수는 다소 또한 코드에 의해 열린 새 메일의 제목에 가야 라인을 복사 한이

Mailbox Details 
============================================================================== 
Mailbox:   /xxxxxx/xxxxxxxxxx/xxxxxxxxx 
Message Name:  xxxxxxxxxxxxxxxxxxxxxxxxx 
Message Id:  xxxxxxxxxxxxxxx 
============================================================================== 

처럼

메일이 보이는 다릅니다. 이것은 제가 지금 당장 가지고있는 것입니다. 제가 누락 된 부분은 그 주제에 특정 라인을 복사하는 방법입니다.

Sub SterlingForward() 

Set objItem = ForwardB() 
Set objItem = ForwardA() 

End Sub 


Function ForwardA() As Object 
Dim oAccount As Outlook.Account 
Dim initialSubj, finalSubj As String 
Dim oMail As Outlook.MailItem 
Set oMail = Application.ActiveExplorer.Selection(1).Reply 
oMail.SentOnBehalfOfName = "[email protected]" 
oMail.To = "[email protected]" 
oMail.Display 



Set myitem = Application.ActiveInspector.CurrentItem 
initialSubj = myitem.Subject 
initialBod = myitem.Body 

finalSubj = ?????????????????????? 


finalBody = "Hello Team," + vbCrLf + "resend was successful" + vbCrLf & CStr(initialBod) 
myitem.Subject = finalSubj 
myitem.Body = finalBody 


End Function 

Function ForwardB() As Object 
Dim objMail As Outlook.MailItem 
Dim initialSubj, initialBod, finalSubj, finalBody As String 
Set objItem = GetCurrentItem() 
Set objMail = objItem.Forward 
objMail.To = "[email protected]" 
objMail.Display 
Set objItem = Nothing 
Set objMail = Nothing 


Set myitem = Application.ActiveInspector.CurrentItem 
initialSubj = myitem.Subject 
initialBod = myitem.Body 

finalSubj = ???????????????????????????? 

finalBody = "Hello Team," + vbCrLf + "resend was successful" + vbCrLf & CStr(initialBod) 
myitem.Subject = finalSubj 
myitem.Body = finalBody 


End Function 

Function GetCurrentItem() As Object 
Dim objApp As Outlook.Application 
Set objApp = Application 
On Error Resume Next 
Select Case TypeName(objApp.ActiveWindow) 
Case "Explorer" 
Set GetCurrentItem = _ 
objApp.ActiveExplorer.Selection.Item(1) 
Case "Inspector" 
Set GetCurrentItem = _ 
objApp.ActiveInspector.CurrentItem 
Case Else 
End Select 
End Function 

답변

0

는 ("사서함"initialBod) http://www.outlookcode.com/codedetail.aspx?id=89

finalSubj = ParseTextLinePair를 참조하십시오이 아직도 날을주고있다

Function ParseTextLinePair(strSource As String, strLabel As String) 
Dim intLocLabel As Integer 
Dim intLocCRLF As Integer 
Dim intLenLabel As Integer 
Dim strText As String 

' locate the label in the source text 
intLocLabel = InStr(strSource, strLabel) 
intLenLabel = Len(strLabel) 
    If intLocLabel > 0 Then 
    intLocCRLF = InStr(intLocLabel, strSource, vbCrLf) 
    If intLocCRLF > 0 Then 
     intLocLabel = intLocLabel + intLenLabel 
     strText = Mid(strSource, _ 
         intLocLabel, _ 
         intLocCRLF - intLocLabel) 
    Else 
     intLocLabel = Mid(strSource, intLocLabel + intLenLabel) 
    End If 
End If 
ParseTextLinePair = Trim(strText) 
End Function 
+0

"오류를 컴파일하는 ByRef 인수 형식이 일치를" 내 다른 기능은 모두 type Object – user2970215

+0

@ user2970215 ForwardA 및 ForwardB에서 Dim initialBod As String을 시도하십시오. 장래에 Option Explicit을 고려할 수도 있습니다. – niton

+0

intialBod는 A와 B 모두에서 선언되지만 동일한 오류가 여전히 발생합니다. 내 A와 B가 객체로 선언 되었기 때문에 그렇지 않습니까? 또한 intialBod는 다음과 같은 방식으로 추출됩니다. "initialBod = myitem.Body" – user2970215