用于转换pdf和电子邮件的excel表格的Vb代码。 [英] Vb code for excel sheet raw to convert pdf and email.
本文介绍了用于转换pdf和电子邮件的excel表格的Vb代码。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
sn edress subj Attachment
1 chintu.@gmail.com Form 16 C:\test\F_810826745_PART A.pdf
2 chintu1@gmail.com Form 16 C:\test\F_810826745_PART B.pdf
3 chint112@gmail.com Form 16 C:\test\F_810826745_PART c.pdf
excel中有3000行想要通过附加邮件发送文件。
我有代码,但附件没有工作。你可以指导我如何添加附件吗。
我尝试过:
VB代码如下。
there is a 3000 row in excel and want to send file in attached mail.
I have code but attachment is not working on it. can you please guide me how do i add attachment in to it.
What I have tried:
VB code are as under.
Sub Macro2()
Dim olapp As Outlook.Application
Dim olmail As Outlook.MailItem
For i = 2 To 4
Set olapp = New Outlook.Application
Set olmail = olapp.createitem(olmailitem)
With olmail
.To = Cells(i, 1).Value
.Subject = Cells(i, 2).Value
.body = Cells(i, 3).Value
.Attachments.Add.Source "D2"
.Display
'olmail.send
End With
Set olmail = Nothing
Set olapp = Nothing
Next
End Sub
推荐答案
你就在那里......没有必要继续创建一个Outlook insta每行的nce虽然
You're just about there... There is no need to keep creating an Outlook instance for each row though
Sub PleaseGiveMeAMeaningfulName()
Dim olapp As New Outlook.Application
Dim olmail As Outlook.MailItem
For i = 2 To 4 'Why only these rows?
'Don't do this in the loop! ... Set olapp = New Outlook.Application
Set olmail = olapp.CreateItem(olmailitem)
With olmail
.To = Cells(i, 1).Value
.Subject = Cells(i, 2).Value
.body = Cells(i, 3).Value
.Attachments.Add Cells(i,4).Value
.Display
'.Send
End With
Set olmail = Nothing
Next
Set olapp = Nothing
End Sub
这篇关于用于转换pdf和电子邮件的excel表格的Vb代码。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文