Excel은 VBA를 이용해 메일을 보냅니다.

4273 단어 Excel
Sub Sendmail()

   Application.ScreenUpdating = False

   On Error Resume Next

   Dim Temp As Object

   Dim Newmail As Object

   Dim strg As String

   Dim strEmpId As String

   Dim email As Excel.Application, emailBook As Excel.Workbook

   Set email = CreateObject("excel.application")

   Set emailBook = email.Workbooks.Open("D:\emailTemplate.xlsx")

   Set Temp = CreateObject("outlook.application")

   Set Newmail = Temp.CreateItem(0)

   With Newmail

       With emailBook

           .To = .Sheets(1).Range("a1")

           '.CC = ""

           .Subject = "<strong>" & .Sheets(2).Range("a1") & "</strong>"

           .Body = .Sheets(2).Range("a2")

           .Attachments.Add ("D:\" & strEmpId & ".docx")

           .Send

       End With

   End With

   Set Temp = Nothing

   Set Newmail = Nothing

   Application.ScreenUpdating = True

End Sub

좋은 웹페이지 즐겨찾기