|
本帖最后由 daqinqin 于 2024-3-6 17:14 编辑
这个vba就是将“列表”中B列的邮箱地址作为发件人发出去。
发邮件倒是没什么问题,但是没有显示发件人,就很不完美。。如下图所示。。发件人那一块是空的。但对方确实收到了邮件。
红色的那一段是网上找的方法,但是不会用。。打没有大佬帮忙解决下
Option Base 1
Sub Send_Email_Macro()
Dim n%
n = ThisWorkbook.Sheets("列表").[B65536].End(3).Row
For i = 2 To n
Call Send_Email_By_Outlook(i)
Next i
End Sub
Sub Send_Email_By_Outlook(ByVal i As Integer)
'On Error Resume Next
Start = Timer
Application.ScreenUpdating = False
Dim Temp As Object, Newmail As Object, strg$
Set Temp = CreateObject("Outlook.Application")
Set Newmail = Temp.CreateItem(olMailItem)
Email_From = "xx@outlook.com"
Email_To = ThisWorkbook.Sheets("列表").Cells(i, 1) '"2@outlook.com"
Email_Subject = "Intermediate supplier"
Email_Body = ThisWorkbook.Sheets("发邮件").Cells(1, 1)
With Newmail
.To = Email_To
.Recipients.Add (ThisWorkbook.Sheets("列表").Cells(i, 1))
'.CC = Email_Cc
.Subject = Email_Subject
.Body = Email_Body
' .Attachments.Add ThisWorkbook.Path & "\" & ThisWorkbook.Name '添加附件
.Send
End With
Application.ScreenUpdating = True
Set Temp = Nothing
Set Newmail = Nothing
'MsgBox Format(Timer - Start, "0.00")
End Sub
|
|