yihren
2008-10-22 15:40:01 UTC
如題所述
用了一段VBA
Sub 寄EMAIL()
Dim i As Integer
Dim myOlApp As Outlook.Application
Dim myMail As Outlook.MailItem
Dim myBody As String
Dim Receiver As String
Set myOlApp = CreateObject("OutLook.Application")
For i = 1 To 100
Set myMail = myOlApp.CreateItem(olMailItem)
myMail.Fristname = Cells(2 + i, 4).Value
myMail.item01 = Cells(2 + i, 5).Value
Receiver = Cells(2 + i, 6).Value
myBody = myMail.Fristname & "先生" & vbCrLf & vbCrLf
myBody = myBody & "標題為:" & vbCrLf
myBody = myBody & myMail.item01
With myMail
.To = Receiver '收件人地址
.Subject = "如信件內容" '郵件主體
.Body = myBody '信件內容
'.Attachments.Add AttachedObject '黏貼附件
.Display
.Send
End With
Next i
Set myOlApp = Nothing
End Sub
為什麼 myMail.Fristname = Cells(2 + i, 4).Value
myMail.item01 = Cells(2 + i, 5).Value
這兩行不能執行 請各位大大救救我
用了一段VBA
Sub 寄EMAIL()
Dim i As Integer
Dim myOlApp As Outlook.Application
Dim myMail As Outlook.MailItem
Dim myBody As String
Dim Receiver As String
Set myOlApp = CreateObject("OutLook.Application")
For i = 1 To 100
Set myMail = myOlApp.CreateItem(olMailItem)
myMail.Fristname = Cells(2 + i, 4).Value
myMail.item01 = Cells(2 + i, 5).Value
Receiver = Cells(2 + i, 6).Value
myBody = myMail.Fristname & "先生" & vbCrLf & vbCrLf
myBody = myBody & "標題為:" & vbCrLf
myBody = myBody & myMail.item01
With myMail
.To = Receiver '收件人地址
.Subject = "如信件內容" '郵件主體
.Body = myBody '信件內容
'.Attachments.Add AttachedObject '黏貼附件
.Display
.Send
End With
Next i
Set myOlApp = Nothing
End Sub
為什麼 myMail.Fristname = Cells(2 + i, 4).Value
myMail.item01 = Cells(2 + i, 5).Value
這兩行不能執行 請各位大大救救我