Current location - Quotes Website - Personality signature - Excel VBA controls Outlook sending and how to set the text color.
Excel VBA controls Outlook sending and how to set the text color.

Refer to the VBA code below

Sub Send_Email()

Dim i As Integer

Dim MyOutlookApp As Outlook.Application

Dim MyFolder As Outlook.MAPIFolder

Dim MyNewMail As Outlook.MailItem

Dim MyAttachments As Outlook.Attachments 'Attachments

Set MyOutlookApp = New Outlook .Application

Set MyFolder = MyOutlookApp.GetNamespace( "MAPI ").GetDefaultFolder(olFolderInbox).Folders( "My Mail Folder")

Set MyNewMail = MyOutlookApp.CreateItem( olMailItem)

With MyNewMail

.To = "YourFridentMail@sina.com " 'Target email address

.Cc="aaa@qq.com"< /p>

.Subject = "test " 'Title

.HTMLBody = "

This is red

"

.AlternateRecipientAllowed = True 'This email can be forwarded

.AutoForwarded = True 'This email allows automatic forwarding

.DeleteAfterSubmit = False 'Keep a copy after sending

'Move to the specified folder after sending

.SaveSentMessageFolder = MyOutlookApp.GetNamespace( "MAPI ").GetDefaultFolder(olFolderInbox).Folders( "Backup Folder ")

.ReadReceiptRequested = True 'Require recipient receipt

'SaveSentMessageFolder

End With

'Attachment

Set MyAttachments = MyNewMail.Attachments

MyAttachments.Add "c:\win\abc.txt ", olByValue

MyNewMail.Save 'Save

MyNewMail.Send 'Send

MyFolder.Display 'Display office outlook

End Sub