Excel VBA: Auto-Emailer, Mark Important, Delivery Receipt etc.
Hi,
I have attached some working code which I use for an auto emailer in one of my workbooks. I have tried unsuccessfully to amend this code so that it will also mark the email as "Important" as well as providing me a "Delivery Receipt". I know this is possible, I just cannot figure it out:confused:... and I know it's probably something extremely easy, but nonetheless it continually evades me:afrog:. Please help. And thanks in advance.
Code:
Sub SendEmail()
Dim OutlookApp As Outlook.Application
Dim MItem As Outlook.MailItem
Dim cell As Range
Dim Subj As String
Dim EmailAddr As String
Dim Recipient As String
Dim Msg As String
'Create Outlook object
Set OutlookApp = New Outlook.Application
'Loop through the rows
For Each cell In Columns("q").Cells.SpecialCells(xlCellTypeVisible)
If cell.Value Like "*@*" Then
EmailAddr = EmailAddr & ";" & cell.Value
End If
Next
Msg = ""
Msg = Msg & "All," & vbCrLf & vbCrLf
Msg = Msg & "Please See Attachment. This is your copy of: "
Msg = Msg & Range("t6").Text & vbCrLf & vbCrLf 'Change the reference when needed -- DH
Msg = Msg & "Of Contract #: "
Msg = Msg & Range("t5").Text & vbCrLf & vbCrLf 'Change the reference when needed -- DH
Msg = Msg & "No Reply Necessary." & vbCrLf & vbCrLf
Msg = Msg & "D.H." & vbCrLf
Msg = Msg & "Contracts" & vbCrLf & vbCrLf & vbCrLf
Subj = "New Contract For Your Copy"
'Create Mail Item and view before sending
Set MItem = OutlookApp.CreateItem(olMailItem)
With MItem
.To = EmailAddr
.Subject = Subj
.Body = Msg
.Display
End With
End Sub
Re: Excel VBA: Auto-Emailer, Mark Important, Delivery Receipt etc.
Also, if you have any alternate ways of writing this code which would simplify it, I'd welcome the learning experience. I know there has to be an easier way, this was the only way I could get it to work for me at the time. #StillLearning
Re: Excel VBA: Auto-Emailer, Mark Important, Delivery Receipt etc.
try
Code:
.importance = olImportanceHigh
.OriginatorDeliveryReportRequested = True
Re: Excel VBA: Auto-Emailer, Mark Important, Delivery Receipt etc.
thank you, it works perfectly. I had tried to make the .Importance = True ... would be nice if that would work as well, I wouldn't have known otherwise, but I know now.
Do you know of any particular resources that teach these commands? Even just the most basic or to provide a clear understanding of the framework of VBA? I'm learning, but it feels like I'm learning it the hard way all the time.
Re: Excel VBA: Auto-Emailer, Mark Important, Delivery Receipt etc.
Quote:
but it feels like I'm learning it the hard way all the time.
lol
most of the information is in the vba help file, that is where i looked the value
else google
unfortunately, as there are multi values for importance, vba true = -1, is not one of them, false = 0 may well work, but not give the desired result to turn off
Re: Excel VBA: Auto-Emailer, Mark Important, Delivery Receipt etc.
Quote:
Originally Posted by
westconn1
lol
most of the information is in the vba help file...
Where is this VBA help file... why do I feel like Corky right now... This information might save me a lot of trouble. :blush:
Re: Excel VBA: Auto-Emailer, Mark Important, Delivery Receipt etc.
Quote:
Where is this VBA help file
on the CD
silly as it may seem the VBA help file is an optional install when installing office
i always do a custom install so i can select VBA help and deselect the stupid office assistant (paperclip)
F1 on any object property or method should bring up context help