Send Email from VBA

R

Rick S.

How or can I setup the body of an email to have more than one line?
Can I open a template? How?
'======
With oMailItem
.Subject = "The extract has finished."
.Body = "This is an automatic email notification"
'======
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007
 
R

Rick S.

Original Code: (Thx Bob Phillips):
How do I get rid of the security prompt? (it comes up two times?).

'======
Private Sub CommandButton2_Click()
Dim oOutlook As Object
Dim oMailItem As Object
Dim oRecipient As Object
Dim oNameSpace As Object


Set oOutlook = CreateObject("Outlook.Application")
Set oNameSpace = oOutlook.GetNameSpace("MAPI")
oNameSpace.Logon , , True


Set oMailItem = oOutlook.CreateItem(0)
Set oRecipient = _
oMailItem.Recipients.Add("(e-mail address removed)")
oRecipient.Type = 1 '1 = To, use 2 for cc
'keep repeating these lines with
'your names, adding to the collection.
With oMailItem
.Subject = "This is an automatic email notification: Bad Link
from SPEC INDEX Excel File!"
.body = "(Please enter the ""Spec Name"", ""Worksheet Name"" and
""Cell Address"" and a brief description of the problem!)"
' .Attachments.Add ("filename") 'you only need this if
'you are sending attachments?
.Display 'use .Send when all testing done
End With

Set oRecipient = Nothing
Set oMailItem = Nothing
Set oNameSpace = Nothing
Set oOutlook = Nothing
End Sub
'======
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007
 
R

Rick S.

JP, Ron thanks!
Is there a way to send the cursor to a specific place in the email?
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007
 
R

Rick S.

I have created what is called a "Live Document" (Excel). it contains
specifications that are interlinked to superseding and or current
specifications.
When a user finds a dead or bad link (hyperlink and or link to named cells
from user forms) there is a command button to send an email. The email will
provide information to me of where, when and what specification is not
functioning properly.

With your and Ron's help (email side) I now have an email opened with a body
of text to auto fill. Only odd characteristic of this, is, the cursor is at
the beginning of the email (top left corner).

No biggie tho, I do appreciate the help I have received. ;)
--
Regards

VBA.Noob.Confused
XP Pro
Office 2007



JP said:
What are you trying to do?


--JP
 
J

JP

You're welcome!

ps- I don't believe there is a way you can place the cursor anywhere
else.


--JP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top