通过电子邮件发送电子表格

嗨,我遇到了一个问题,试图通过Excel发送电子邮件。 我正在尝试从Excel中发送一个电子邮件,其中显示了一个时间表。

在这里输入图像说明

星期五我能够得到电子邮件发送,但现在似乎没有工作。 也许它只是需要一段时间发送我不敢肯定。

我希望能够发送颜色的范围,如果可能的话,我不知道这是可能的。

任何帮助将非常感激

Private Sub SendEmail() Dim OutApp As Object Dim OutMail As Object Dim strbody As String Set OutApp = CreateObject("Outlook.Application") Set OlObjects = OutApp.GetNamespace("MAPI") Set OutMail = OutApp.CreateItem(olMailItem) On Error Resume Next With OutMail .To = ("xxxx@hotmail.com") .Subject = "Test Mail" .Body = "This is a test email." & Time ' Time refers to a range of cells eg a1:h15 .Display .Send End With End Sub 

这里试试这个。 这是我从以前的程序中写出来的东西,与您正在进行的操作是一样的。 如果使用“ .Send ,请.Send 。您需要从Outlook中“确定”popup窗口。

 '-------Send Mail---------- strbody = "TEST:" & strbody 'Build header. Dim OutApp As Object Dim OutMail As Object Set OutApp = CreateObject("Outlook.Application") OutApp.Session.Logon Set OutMail = OutApp.CreateItem(0) On Error Resume Next With OutMail .To = "test@something.com" 'Email to be sent to here. .cc = "" .BCC = "" .Subject = "Test! " & Format(Date, "mmm-dd-yy") .Body = strbody .attachments.Add ActiveWorkbook.FullName .Display 'Can use .Send however it will ask for verification within outlook End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing