ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Send Email from VBA (https://www.excelbanter.com/excel-programming/404040-send-email-vba.html)

Rick S.

Send Email from VBA
 
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


Rick S.

Send Email from VBA
 
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 = _
om")
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



"Rick S." wrote:

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


JP[_4_]

Send Email from VBA
 
You could try

.Body = "This is line 1" & vbcr & "This is line 2"



HTH,
JP

On Jan 10, 3:09*pm, Rick S. wrote:
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



Ron de Bruin

Send Email from VBA
 
See
http://www.rondebruin.nl/mail/prevent.htm



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Rick S." wrote in message ...
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 = _
om")
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



"Rick S." wrote:

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


Rick S.

Send Email from VBA
 
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



"JP" wrote:

You could try

.Body = "This is line 1" & vbcr & "This is line 2"



HTH,
JP

On Jan 10, 3:09 pm, Rick S. wrote:
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




JP[_4_]

Send Email from VBA
 
What are you trying to do?


--JP

On Jan 10, 4:16*pm, Rick S. wrote:
JP, Ron thanks!
Is there a way to send the cursor to a specific place in the email?
--
Regards



Rick S.

Send Email from VBA
 
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" wrote:

What are you trying to do?


--JP

On Jan 10, 4:16 pm, Rick S. wrote:
JP, Ron thanks!
Is there a way to send the cursor to a specific place in the email?
--
Regards




JP[_4_]

Send Email from VBA
 
You're welcome!

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


--JP


On Jan 10, 4:56*pm, Rick S. wrote:
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




All times are GMT +1. The time now is 02:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com