URGENT!!! VBA Sending Email Using Connection String

jamesmev

Board Regular
Joined
Apr 9, 2015
Messages
233
Office Version
  1. 365
Platform
  1. Windows
Trying to use a Server connection string on my current list.


Sub SendByOne()
Dim c As Range
Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim i As Integer
On Error Resume Next


For Each c In Range("B2:B" & Cells(Rows.Count, "B").End(xlUp).Row).Cells
picName = c.Offset(0, 2).Value
picName2 = c.Offset(0, 3).Value
picname3 = c.Offset(0, 6).Value
Set OutLookApp = CreateObject("Outlook.application")
Set OutLookMailItem = OutLookApp.CreateItem(0)
With OutLookMailItem
'.SentOnBehalfOfName = "gmat"
.To = c.Offset(0, 4).Value

.Subject = c.Offset(0, 1).Value
.attachments.Add picName
.attachments.Add picName2
.attachments.Add picname3


.htmlbody = " "
.htmlbody = .htmlbody & c.Offset(0, 5).Value & "</b>"
.htmlbody = .htmlbody & "<br> " & c.Offset(0, 7).Value
.htmlbody = .htmlbody & "<br><b><font size='3'>" & c.Offset(0, 8).Value & "</font>"

.htmlbody = .htmlbody & "<br> <br> <br> <br> </b> Dear Valued Customer"
'Introduction
.htmlbody = .htmlbody & "<br> <br> text"

.htmlbody = .htmlbody & "<br> <br> *text."
.htmlbody = .htmlbody & "<br> <br> text request."


' .HTmlbody = .HTmlbody & "<br>If you would like to embed my latest video you can find it here"
' .HTmlbody = .HTmlbody & "<br> Check it out <a href = ""URL HERE""> HERE </a>"
.display 'to display first
'.Send 'to send it in background
End With
Next c

End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.

Forum statistics

Threads
1,215,424
Messages
6,124,817
Members
449,190
Latest member
rscraig11

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