2013-06-28 49 views
1

我目前有一個VBA代碼,選擇一個自定義範圍,然後通過電子郵件將所選範圍通過電子郵件發送到另一個工作表中。我附上了代碼,但是這個代碼被複制並粘貼了8次(有8個塊)...... Idk如果重要,但只是認爲我應該儘可能多地提供信息。這些是我的兩個問題:VBA代碼顯示電子郵件,而不是自動發送

1)如何顯示在Outlook上的電子郵件窗口,而不是自動發送(我已經嘗試.Item.Display,它不起作用,所以任何替代或任何其他方法,請推薦) 2)如何讓選定的範圍保持其格式(一些文本是紅色的,但一旦在電子郵件中發送則顯示爲默認文本)。

在此先感謝。

 For Each aCell In Worksheets("Email List").Range("B3:B" & Cells(Rows.Count, "B").End(xlUp).Row) 
      If aCell <> "" Then 
        eTo = eTo & aCell & ";" 
       End If 
    Next 
    eTo = Left(eTo, Len(eTo) - 1) 
    If IsEmpty(Range("B4")) Then 
    Else 
     ActiveSheet.Range("a3", ActiveSheet.Range("e3").End(xlDown)).Select 
     ActiveWorkbook.EnvelopeVisible = True 
    With ActiveSheet.MailEnvelope 

     .Item.To = eTo 
     .Item.Subject = "Allocations - Barclays" & Format(Date, " mm/dd/yyyy") 
     .Item.Send 
    End With 
    End If 

回答

0

我用這個和它的作品 - 這將顯示郵件,但可以改變:

With OutMail 
     .To = mailName ' This is the name of the person to review the documents. 
     .CC = "" 
     .BCC = "" 
     .Subject = "Please review the attached." 
     .HTMLBody = RangetoHTML(rng) 
     .Display 'or use .Send 
    End With 

看看http://www.rondebruin.nl/win/s1/outlook/bmail2.htm 這對郵寄範圍從Excel的前景極好的信息。