VBA opening Outlook email from Excel

bjornltd

New Member
Joined
Mar 8, 2013
Messages
14
Hi

I am very new to VBA and need some help figuring this out. Greatly appreciate any help. I have searched and tried to change some solutions to my needs, but I’m coming up short…

Case:

By pressing a button, in Excel, the user of the workbook (there are several users), should open a new Outlook email with:
  • Email sent on behalf of:
    • If cell B42:
      • States “A”, send from “#1” email account
      • States “B”, send from “#2” email account
      • States “C”, send from “#3” email account
  • To: Value in cell B37
  • Subject: “Fixed text” + value of cell B44
  • Signature in HTML from the current user. The signatures of the users don’t have the same filename.
All the information is in the same Excel sheet.

Sorry if this has been answered before, just could not find a solution that suits my needs. Thanks for any help :)
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
Hi,

I have actually looked at this, but my skillset in VBA is really bad! I really don’t understand how to get it right!
I tried some different solutions, but either I get an error message or nothing happens…..
 
Upvote 0
Try this:

Dim OlApp As Object
Dim NewMail As Object
Dim selectedemail As String

Set OlApp = CreateObject("Outlook.Application")
Set NewMail = OlApp.CreateItem(0)

Select Case Cells.Range("B42").Value
Case "A"
selectedemail = "#1@email.com"
Case "B"
selectedemail = "#2@email.com"
Case "C"
selectedemail = "#3@email.com"

End Select
With NewMail
.To = selectedemail
.Subject = "Fixed Text " & Cells.Range("B42").Value
.display
End With
Set NewMail = Nothing
Set OlApp = Nothing
 
Upvote 0

Forum statistics

Threads
1,215,066
Messages
6,122,948
Members
449,095
Latest member
nmaske

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top