標題: [發問] 請問用VBA程式呼叫 OUTLOOK EXPRESS [打印本頁] 作者: PD961A 時間: 2011-5-18 00:18 標題: 請問用VBA程式呼叫 OUTLOOK EXPRESS
請問用VBA程式呼叫 OUTLOOK EXPRESS 發送本文給工作表上多位收信者,如何自動送出..謝謝作者: chin15 時間: 2011-5-18 14:44
大約如此吧,沒測試不知是否有bug
在設定引用項目中引用outlook object library
程式
Dim objOutlook As New Outlook.Application
Dim objMail As MailItem
Set objOutlook = New Outlook.Application
Set objMail = objOutlook.CreateItem(olMailItem)
for each a in [a1:a10] '放置信箱
With objMail
.To = a '設置收件人信箱,有多人可設置變數來循環
.Subject = "你好嗎" '設置郵件主題
.Body = "我很好!" '設置郵件內容
.Attachments.Add "C:\abcd.TXT" '設置附件
.Send '發送郵件
End With
Application.Wait (Now + TimeSerial(0, 0, 5))'設置等待時間進行下一個
Next
Set objMail = Nothing '釋放物件
Set objOutlook = Nothing '釋放物件作者: PD961A 時間: 2011-5-18 20:33
用以下shell函數,利用for next 寄了50封左右但常會顯示寄送失敗無法全部傳出,不知是否還有其他參數可用?
For i = 2 To 50
mymail = Range("g" & i)
myno = Range("c" & i)
main = Range("c" & i) Shell "C:\Program Files\Outlook Express\msimn.exe " & "/mailurl:mailto:" & mymail & "?subject=" & myno & "&Body=" & main, vbMaximizedFocus
next i作者: PD961A 時間: 2011-5-25 19:45
謝謝gb版主
請問以下的程式碼可以加傳附件嗎?謝謝您
Sub SendMail()
With Application.ActiveSheet.MailEnvelope
'Add some introductory text before the body of the e-mail.
.Introduction = "Please read this and send me your comments."
'Return a Microsoft Outlook MailItem object that
'you can use to send the document.
With .Item
'All of the mail item settings are saved with the document.
'When you add a recipient to the Recipients collection
'or change other properties, these settings will persist.
.Recipients.Add "[email protected]"
.Subject = "Here is the Sheet"
'The body of this message will be
'the content of the active document.
.Send
End With
End With
End Sub作者: GBKEE 時間: 2011-5-25 20:51