Objectives: Auto-create and email in display mode where the FROM, TO, SUBJECT and some of the BODY are auto-populated
* FROM: AMLC@emailaddy.com
* TO: Maria@emailaddy.com
* Store copy in SENT folder for the AMLC mailbox
Problems:
* I cannot get the FROM to stop defaulting to the user's primary email address.
* A copy of the sent email keeps going into the user's SENT folder instead of the SENT folder for the AMLC mailbox
I have the following script that is launched by a user from an excel form as needed:
As you can see, I have tried a few different ways to get the "FROM" field populated in the email. The closest working solution was using ".SentOnBehalfOfName", though it doesn't display correctly while the email is being edited. It still shows the user's primary email address until they actually send the email. The correct email address is displayed only AFTER the email is sent.
Can someone help me do what I perceive to be a simple task (see objectives listed above)?
* FROM: AMLC@emailaddy.com
* TO: Maria@emailaddy.com
* Store copy in SENT folder for the AMLC mailbox
Problems:
* I cannot get the FROM to stop defaulting to the user's primary email address.
* A copy of the sent email keeps going into the user's SENT folder instead of the SENT folder for the AMLC mailbox
I have the following script that is launched by a user from an excel form as needed:
VBA Code:
Sub SendMariaEmail()
'
'Send email to Maria to verify PNs that are out of tolerance based on values in BOM
'
Dim OutApp As Object
Dim OutMail As Object
Dim Signature As String
Dim strFrom As String
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.Display
End With
Signature = OutMail.htmlbody
With OutMail
' .SentOnBehalfOfName = "[EMAIL]AMLC@emailaddy.com[/EMAIL]" <---------THIS SOLUTION SORT OF WORKS, BUT PUTS THE SENT COPY IN THE USER'S SENT FOLDER, NOT IN THE SENT FOLDER FOR THE AMLC MAILBOX
' outlookmailitem.SendUsingAccount = OutApp.session.accounts.Item(2) <---------THIS SOLUTION DID NOT WORK AT ALL
strFrom = "[EMAIL]AMLC@emailaddy.com[/EMAIL]" <---------THIS SOLUTION DID NOT WORK AT ALL
.To = "[EMAIL]Maria@emailaddy.com[/EMAIL]"
.CC = ""
.BCC = ""
.Subject = Range("B4") & " - BOM Details to Verify for AMLC - " & Range("B9") & ", Assembly: " & Range("B5")
.htmlbody = "Maria," & "<br><br>" & "Can you please verify the information below and get back to me ASAP?" & "<br><br>" & "<i>*Please note that the agreed-upon SLA for AMLCs are a 24-hour turnaround from the time Customer Service submits them for processing to the time they get them back to hand it over to Glen.</i>" & "<br><br>" & Signature
' .Attachments.Add ActiveWorkbook.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Display 'or use .Send
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
As you can see, I have tried a few different ways to get the "FROM" field populated in the email. The closest working solution was using ".SentOnBehalfOfName", though it doesn't display correctly while the email is being edited. It still shows the user's primary email address until they actually send the email. The correct email address is displayed only AFTER the email is sent.
Can someone help me do what I perceive to be a simple task (see objectives listed above)?
Last edited by a moderator: