ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Email Macro only sometime works? (https://www.excelbanter.com/excel-discussion-misc-queries/104990-email-macro-only-sometime-works.html)

PaulW

Email Macro only sometime works?
 
Range("T4").Select
ActiveCell.FormulaR1C1 = "1"

Do Until cont = 44

cont = Range("T4").Value
dothing = Range("N15").Value

If dothing 0 Then

mail = Range("W4").Value
rang = Range("AK2").Value

Dim iMsg As Object
Dim iConf As Object
Dim sh As Worksheet
Dim rng As Range
Dim Flds As Variant

Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")

iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")
= 2

..Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "******"

..Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Update
End With

Set sh = Sheets("Mail")
Set rng = sh.Range(rang)

With iMsg
Set .Configuration = iConf
.To = mail
.CC = ""
.BCC = ""
.From = """Paul"" <*******"
.Subject = "Your Current Closures"
.HTMLBody = RangetoHTML(sh, rng)
.Send
End With

Set iMsg = Nothing
Set iConf = Nothing


Else
End If

Windows("Daily Advisor Stats.xls").Activate
Sheets("Calc").Select

Range("T6").Select
Selection.Copy
Range("T4").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False

Loop


This is sends data from the "Mail" sheet, based on what number is in T4,
each number is for a different person. In this way it should send to each
individual information on their own figures.

When I change the email address from W4, to W3 (and in W3 I have the email
address of the bloke sat across from me) it sends fine. But when its on W4,
where the email address of the individual will be updated it doesn't send,
don't even get an error.

Will this just not work on External email, only Internal? Or do I need to
use a different smtpserver? Even when I put my address in the BCC I don't get
sent it...

Also, when they go through internally, they are centre adjusted in the
email, rather than left adjusted....


All times are GMT +1. The time now is 04:13 PM.

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