Adding the .From or another way

Boyler88

New Member
Joined
Aug 23, 2012
Messages
7
hi all, i am hoping you can help. I am trying to either add .from to the below code! Any help would be amazing!

Sub SendEmail()

Application.ScreenUpdating = False

Dim OutlookApp As Object
Dim MItem As Object
Dim cell As Range
Dim Subj As String
Dim EmailAddr As String
Dim Account As String
Dim Invoice As String
Dim Amount As String
Dim Answer As String
Dim MyNote As String


MyNote = "Do you realy want to do this?"
Answer = MsgBox(MyNote, vbQuestion + vbYesNo, "???")

If Answer = vbNo Then

MsgBox ""
Else

Sheets("Send").Activate
Set ob***p = CreateObject("Outlook.Application")

For Each cell In Columns("J").Cells.SpecialCells(xlCellTypeConstants)
If cell.Value Like "*@*" Then
EmailAddr = cell.Value
Account = cell.Offset(0, -9).Value
Invoice = cell.Offset(0, -8).Value
Amount = cell.Offset(0, -7).Value
Store = cell.Offset(0, -6).Value

Msg =
Msg =
Msg =
Msg =

Subj =

Set OutlookApp = CreateObject("Outlook.Application")
Set MItem = OutlookApp.CreateItem(0)
With MItem
.To = EmailAddr
.Subject = Subj
.Body = Msg
SendKeys ("{ENTER}")
.Display
SendKeys ("%{s}")



End With

newHour = Hour(Now())
newMinute = Minute(Now())
newSecond = Second(Now()) + 1
waitTime = TimeSerial(newHour, newMinute, newSecond)
Application.Wait waitTime

End If

Next
End If
End Sub
If this cannot be done then is there a way to add this there (baring in mind this will be sent from excel)

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Item.ReplyRecipients.Add "creditcontrol@dsgibusiness.com"
Item.ReplyRecipients.Item(1).Resolve
Item.Save
End Sub

Thanks Steve
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
are you sending it from your own account or a shared account you have access to
 
Upvote 0
try replacing your with to end with code with the following and edit accordingly, removing the comment character at the start of the line for required bits
Code:
With MItem
    .Subject = "Salary Info"
    .Recipients.Add PSS_EmailAddress
    .Body = "Please Find attached Salary Spreadsheet"
    .Attachments.Add "C:\Salary.xls"
'        .OriginatorDeliveryReportRequested = True
'        .ReadReceiptRequested = True
'    .SentOnBehalfOfName = "Admin"
    .Send
End With
 
Upvote 0
Well i gave it a go as best i could and it just wouldn't work anyway.

When i replced with End With and edited as you suggested it simply told me End with no with... :S
 
Upvote 0
You need to replace your completed with .. End with block
 
Upvote 0
You need to replace your completed with .. End with block

Nope :( I have tried to changes this and it still does not work. Perhaps i am doing in wrong.

Also i still do not know how that will allow me to enter in a .from line?

As i said i am really new to this so any simple instructions would be most appreciated ;)
 
Upvote 0

Forum statistics

Threads
1,216,115
Messages
6,128,923
Members
449,479
Latest member
nana abanyin

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