How to create an auto email as Task from excel to Outlook with VBA

brcrazy

New Member
Joined
Mar 27, 2018
Messages
4
Hi,

I am looking for a code that will create a new Outlook Task when someone enters a value in a specific row. I use below code that creates a automatic email when someone enters data in row D and would like the exact same result except that it creates an Outlook Task instead of a simple email when someone enters data in column 5.

Can you please let me know how to do this?
I really hope I can use the same code as down below just with a few changes;

Public Sub Worksheet_Change(ByVal Target As Range)
Dim xRgSel As Range
Dim xOutApp As Object
Dim xMailBody As String
On Error Resume Next
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set xRg = Range("D2:D400")
Set xRgSel = Intersect(Target, xRg)
ActiveWorkbook.Save
If Not xRgSel Is Nothing Then
Set xOutApp = CreateObject("Outlook.Application")
Set xMailItem = xOutApp.CreateItem(0)
xMailBody = "Möte med " & Cells(ActiveCell.Row, 1) & Cells(ActiveCell.Row, 4) & xRgSel.Address(False, False) & _
" in the worksheet '" & Me.Name & "' blev bokat " & _
Format$(Now, "mm/dd/yyyy") & " at " & Format$(Now, "hh:mm:ss") & _
" av " & Environ$("username") & "."

With xMailItem
.To = "xxx"
.Subject = "Nytt möte bokat - " & Cells(ActiveCell.Row, 1)
.Body = xMailBody
.Attachments.Add (ThisWorkbook.FullName)
.Display
End With
Set xRgSel = Nothing
Set xOutApp = Nothing
Set xMailItem = Nothing
End If
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
Hi again,

anyone have any idea how I would solve this?

My goal is that someone enters data (with a dropdown) in Column E (for e.g E2:E300) I would like the macro to create an Outlook Task thats being sent to 3 different email addresses. In the same time I want to keep above code that creates a email when someone enters data in column D.

Would really appreciate any kind of help! And Im no wizzard (as you may have noticed) when it comes to VBA so if you can, please send the full code.

Thanks in advance!
 
Upvote 0
Hi again,

anyone have any idea how I would solve this?

My goal is that someone enters data (with a dropdown) in Column E (for e.g E2:E300) I would like the macro to create an Outlook Task thats being sent to 3 different email addresses. In the same time I want to keep above code that creates a email when someone enters data in column D.

Would really appreciate any kind of help! And Im no wizzard (as you may have noticed) when it comes to VBA so if you can, please send the full code.

Thanks in advance!
 
Upvote 0
Hi guys,

is it really no one who knows if or how this is possible? Would really appreciate some expert advice!
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,289
Members
449,077
Latest member
Rkmenon

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