2013-08-08 2 views
1

매크로를 실행하고 이름과 메일 주소를 잘 다듬었지만 다른 줄에 표시되도록 보낸 텍스트를 가져올 수 없다면 긴 줄의 텍스트로 나타납니다. 나는 vbline 등을 추가하는 시도하지만 하위 mailtoo()에 차이이메일에서 별도의 줄에 엑셀 텍스트

을하지

Dim OutApp As Object 

Dim OutMail As Object 

Dim cell As Range 



Application.ScreenUpdating = False 

Set OutApp = CreateObject("Outlook.Application") 



On Error GoTo cleanup 

For Each cell In Columns("b").Cells.SpecialCells(xlCellTypeConstants) 

    If cell.Value Like "?*@?*.?*" And _ 

     LCase(Cells(cell.Row, "c").Value) = "yes" Then 



     Set OutMail = OutApp.CreateItem(0) 

     On Error Resume Next 

     With OutMail 

      .To = cell.Value 

      .Subject = "for Action" 

      .Body = "Dear " & Cells(cell.Row, "A").Value _ 

        & vbNewLine & vbNewLine & _ 

        "line one of text here. " & _ 
        "line two of text here" & _ 
        "line three of text here" & _ 

        "Regards" & _ 

        "your name" 





      .Attachments.Add "C:\demofilename.xlsx" 

      .Send 'Or use Display 

     End With 

     On Error GoTo 0 

     Set OutMail = Nothing 

    End If 

Next cell 

정리 :

Set OutApp = Nothing 

Application.ScreenUpdating = True 

최종 하위 당신은 그 VbNewLine 변수의 사용을 만들 필요가

답변

1

새 텍스트 줄을 표시하려는 위치 :

    & vbNewLine & vbNewLine & _ 

        "line one of text here. " & vbNewLine & _ 
        "line two of text here" & vbNewLine & _ 
        "line three of text here" & vbNewLine & vbNewLine &_ 

        "Regards" & vbNewLine & _ 

        "your name" 

VB 줄 연속 문자 _은 문자열에 특별한 기능을 수행하지 않으며 코드 자체를 읽기 쉽게하기위한 용도로만 사용됩니다. 당신은 런타임에 아무 의미 라인 연속 요청을 제거하면 원래의 코드는 실행됩니다 어떤면에서 같을 것이다 :

"line one of text here. " & "line two of text here" & "line three of text here" & "Regards" & "your name" 
+0

가 치료 환호를 작동 –

관련 문제