仕事上必要な工夫など、備忘録として残します。
Excel等からCDOを利用しメールクライアントを介さずにメールする(2)
GoMail関数改
Sub GoMail(t As Variant, sj As Variant, bd As Variant, Optional at As Variant)
Set objMail = CreateObject("CDO.Message")
Worksheets("setting").Select
With Sheets("setting")
objMail.to = t '送信先アドレス
objMail.Subject = sj 'メール題名
objMail.TextBody = bd '本文
If at <> "" Then objMail.AddAttachment at '添付ファイル
objMail.From = .Range("B1")
chars = .Range("B2")
If chars = "" Then chars = "utf-8"
objMail.BodyPart.Charset = chars
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = .Range("B3")
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = .Range("B4")
objMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = .Range("B5")
objMail.Configuration.Fields.Update
End With
objMail.Send
Set objMail = Nothing
End Sub
このコードは標準モジュールに記載してあります。呼び出し側
プロフィール
カレンダー
ブログ内検索
カテゴリー
最新記事
忍者カウンター
P R