0

私は新しい VBA ユーザーであり、以下のコードを使用して、タイトルで説明したことを達成しようとしています。

cc/bcc/and to に特化したディムの作成と関係があると思いますが、よくわかりません。1 つの列には特定の条件に基づいてフィルター処理された電子メールのリストがあり、そのすぐ隣の列には「」「cc」または「bcc」のいずれかが表示されます。空白の場合は「to」に入り、ccの場合は「.CC」フィールドなどに入ります。

Sub SendList()

'DIM

    Dim olApp As Outlook.Application
    Dim olMail As MailItem
    Dim CurrFile As String
    Dim emailRng As Range, cl As Range
    Dim sTo As String

'SET

    Set emailRng = ActiveSheet.Range("E3:E100").SpecialCells(xlCellTypeVisible)

    For Each cl In emailRng

    sTo = sTo & ";" & cl.Value

    Next

    sTo = Mid(sTo, 2)

    Set olApp = New Outlook.Application
    Set olMail = olApp.CreateItem(olMailItem)

'UPDATE WORKBOOK BEFORE SENDING

    ActiveWorkbook.Save
    CurrFile = ActiveWorkbook.Path & "\" & ActiveWorkbook.Name

'Need to find a way to automate to TO CC and BCC

    With olMail
        .To = sTo
        .CC = ""
        .BCC = ""
        .Subject = "Audit Report XYZ" & " " & "-" & " " & Date
        .Body = .Body & "Test" & vbCrLf & "Test2" & vbCrLf & "Test3"
        .Attachments.Add "C:\Users\uq050e\Downloads\anyfile.xlsx" 'An audit report
        .Display '.Send
    End With

    Set olMail = Nothing
    Set olApp = Nothing

End Sub
4

1 に答える 1

0

問題は Outlook VBA ではなく、Excel のコンテンツの読み取りにあるようです。最初に VBA と Excel を少し学習することをお勧めします。 Excel 2010 で VBA を使い始める を参照してください。

指定したオブジェクト/セルのテキストを取得するには、Range クラスのTextプロパティを使用できます。

于 2015-06-18T16:49:42.880 に答える