CDONTS in Excel for sending mail

Kathleen_0422

Board Regular
Joined
May 5, 2011
Messages
64
In ASP for website coding I can hardcode an email address "sent by" name using CDONTS. I do it all the time.

I am using Nate-O's code in Excel to send information via Lotus Notes. Is it possible to hard-code the sent from address in there?


ASP CODE:

Dim objNewMail, email, subject, msgbody

subject = "WLF Holiday Drive "

msgbody = vbNewLine
msgbody = msgbody & "********** FOR NOTIFICATION PURPOSES ONLY ***********************" & vbNewLine
msgbody = msgbody & "*******************************************************************" & vbNewLine & vbNewLine
msgbody = msgbody & "We have registered your donation of: " & vbNewLine & vbNewLine

Response.write vbNewLine & vbNewLine & vbNewLine

msgbody = msgbody & vbNewLine & vbNewLine & " Donations are needed by end of business on date goes here " & vbNewLine
msgbody = msgbody & " Please bring all donations to your nearest Board member:" & vbNewLine

email = request.form("emailAddress")

'response.write("E-Mail: " & email & "<BR>")
'response.write("Subject: " & subject & "<BR>")

Set objNewMail = Server.CreateObject("CDONTS.NewMail")

:eeek: objNewMail.Send "I_put_Email_Address_here.domain name here.com", email, subject, msgbody, 2


Here is the code from Nate-O which I would like to use if I can hardcode a sent by name.

Sub SendMail()
'Following code was pulled from mrexcel.com for sending emails

Dim Maildb As Object, MailDoc As Object, AttachMe As Object, AttachMe2 As Object, Session As Object
Dim UserName As String, MailDbName As String
Dim EmbedObj1 As Object
Dim EmbedObj2 As Object

Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, _
(Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
Set Maildb = Session.GetDataBase(vbNullString, MailDbName)
If Not Maildb.IsOpen Then Maildb.OpenMail
Set MailDoc = Maildb.CreateDocument
MailDoc.Form = "Memo"

MailDoc.sendto = arrRecips
MailDoc.CopyTo = arrRecipsCC
MailDoc.Subject = "Monthly Budget vs. Actual " & CostCenter 'Subject of e-mail
MailDoc.Body = CustomizeableMsg & vbNewLine & vbNewLine

Set AttachMe = MailDoc.CreateRichTextItem("Attachment")
Set EmbedObj1 = AttachMe.Embedobject(1454, vbNullString, _
"C:\Divisional Budget\" & ProcessPeriod & "\" & NameOfFile & ".xls", "Attachment 1 ") 'Attaches file to e-mail

MailDoc.SaveMessageOnSend = True
MailDoc.PostedDate = Now
 

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.

Forum statistics

Threads
1,224,586
Messages
6,179,719
Members
452,939
Latest member
WCrawford

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