返回列表 上一主題 發帖

用vba 發yahoo GMAIL 的電子郵件不用透過outlook

用vba 發yahoo GMAIL 的電子郵件不用透過outlook

vba 發yahoo GMAIL 的電子郵件不用透過outlook

Sub outfile()
Set myOL = CreateObject("outlook.application")
Set myMail = myOL.createItem(0)
myMail.to = "aaa@gmail.com"
myMail.Subject = "see you sooon"
myMail.body = "execl send to Mail...."
myMail.Display
myMail.send
End Sub
有類似以上的格式  最能夾帶附件
能自動化發email
yes show me money


  1. Option Explicit

  2. Sub SendAsPDF()
  3. '   Uses early binding
  4. '   Requires a reference to the Outlook Object Library
  5.     Dim OutlookApp As Outlook.Application
  6.     Dim MItem As Object
  7.     Dim Recipient As String, Subj As String
  8.     Dim Msg As String, Fname As String
  9.             
  10. '   Message details
  11.     Recipient = "myboss@xrediyh.com"
  12.     Subj = "Sales figures"
  13.     Msg = "Hey boss, here's the PDF file you wanted."
  14.     Msg = Msg & vbNewLine & vbNewLine & "-Frank"
  15.     Fname = Application.DefaultFilePath & "\" & _
  16.       ActiveWorkbook.Name & ".pdf"
  17.    
  18. '   Create the attachment
  19.     ActiveSheet.ExportAsFixedFormat _
  20.         Type:=xlTypePDF, _
  21.         Filename:=Fname
  22.    
  23. '   Create Outlook object
  24.     Set OutlookApp = New Outlook.Application
  25.    
  26. '   Create Mail Item and send it
  27.     Set MItem = OutlookApp.CreateItem(olMailItem)
  28.     With MItem
  29.       .To = Recipient
  30.       .Subject = Subj
  31.       .Body = Msg
  32.       .Attachments.Add Fname
  33.       .Save 'to Drafts folder
  34.       '.Send
  35.     End With
  36.     Set OutlookApp = Nothing

  37. '   Delete the file
  38.     Kill Fname
  39. End Sub
複製代碼

TOP


註:上述程式碼,需要引用”Microsoft Outlook 12.0 Object Library"

TOP

學海無涯_不恥下問

TOP

十分感謝  大大 無私的救援
yes show me money

TOP

        靜思自在 : 對父母要知恩,感恩、報恩。
返回列表 上一主題