2017-03-09 58 views
0

私はExcel VBAでいくつかのコードを持っています。私は電子メールでそれを送る必要があります。それはうまく見えますが、電子メールは受信されません。誰か助けてくれますか?Excel VBA電子メールを送信

i = 4 
Do While Sheets("Data").Cells(i, 1).Value <> "" 
    If Sheets("Data").Cells(i, 11).Value = "Pabaigtas" And Sheets("Data").Cells(i, 12).Value = "NE" And Sheets("Data").Cells(i, 10).Value <> "DONE" Then 
     Sheets("Email").Range("A2:P2").ClearContents 
     Sheets("Data").Range(Cells(i, 1), Cells(i, 16)).Copy 
     Sheets("Email").Range("A2:P2").PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False 
     Sheets("Data").Cells(i, 10).Value = "DONE" 
     Sheets("Email").Activate 
     ActiveSheet.Range("A1:P2").Select 
     ActiveWorkbook.EnvelopeVisible = True 
     With ActiveSheet.MailEnvelope 
      .Introduction = "NEATITIKIMU REGISTRAS" 
      .Item.To = "[email protected]" & ";" & "[email protected]" & ";" & "[email protected]" & ";" & "[email protected]" & ";" & "[email protected]" & ";" & "[email protected]" & ";" & "[email protected]" & ";" & "[email protected]" & ";" & "[email protected]" & ";" & "[email protected]" 
      .Item.Subject = "PABAIGTA UZDUOTIS NEATITIKIMU REGISTRE" 
      .Item.Send 
     End With 
     ActiveWorkbook.EnvelopeVisible = False 
    End If 
    i = i + 1 
Loop 
+0

は、MS Outlookは、標準のメールクライアントですか? ExcelとOutlookのバージョンは何ですか? – Luuklag

答えて

0

私もこの問題を抱えていたと私はOutlookを使用して送信するには、以下のコードを使用:

Public Sub testOutlook() 
    Dim OutApp As Object: Set OutApp = CreateObject("Outlook.Application") 
    Dim OutMail As Object: Set OutMail = OutApp.CreateItem(0) 

    OutMail.Display 
    Signature = OutMail.HTMLBody 
    strbody = "Some text here" 

    With OutMail 
     .SentOnBehalfOfName = "" 
     .To = "" 
     .CC = "" 
     .BCC = "" 
     .Subject = "TEST" 
     .HTMLBody = strbody & Signature 
     .Display 
    End With 
End Sub 
+0

ありがとう!出来た –

関連する問題