473,406 Members | 2,816 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Sending Emails Using a macro

Hi,

I'm trying to send emails using a Macro based on an Excel Sheet and the Email Client I'm using is Lotus Notes.

OS used - Windows Xp.
Language - VB

Below is the Code I'm using for doing the same.

Dim Maildb As Object
Dim UserName As String
Dim MailDbName As String
Dim MailDoc As Object
Dim attachME As Object
Dim Session As Object
Dim EmbedObj1 As Object
Dim recipient As String
Dim ccRecipient As String
Dim bccRecipient As String
Dim subject As String
Dim bodytext As String
Dim Attachment1 As String
Dim t1 As Range

Set t1 = Cells(1, 200)


' setting up all sending recipients
recipient = "" & Addr
ccRecipient = ""
bccRecipient = ""
subject = "" & subj
bodytext = "" & bdy




'// Lets check to see if form is filled in Min req =Recipient, Subject, Body Text
If recipient = vbNullString Or subject = vbNullString Or bodytext = vbNullString Then
MsgBox "Recipient, Subject and or Body Text is NOT SET!", vbCritical + vbInformation
Exit Function
End If

' creating a notes session
Set Session = CreateObject("Notes.NotesSession")
UserName = Session.UserName
MailDbName = Left$(UserName, 1) & Right$(UserName, (Len(UserName) - InStr(1, UserName, " "))) & ".nsf"
Set Maildb = Session.GETDATABASE("", MailDbName)

If Maildb.IsOpen <> True Then
On Error Resume Next
Maildb.OPENMAIL
End If

Set MailDoc = Maildb.CreateDocument
MailDoc.form = "Memo"

' loading the lotus notes e-mail with the inputed data
With MailDoc
.sendto = recipient
.copyto = ccRecipient
.blindcopyto = bccRecipient
.subject = subject
.body = bodytext
End With

' saving message
MailDoc.SaveMessageOnSend = True

Attachment1 = ""
If Attachment1 <> "" Then
Set attachME = MailDoc.CREATERICHTEXTITEM("Attachment1")
Set EmbedObj1 = attachME.EmbedObject(1454, "", Attachment1, "Attachment")
MailDoc.CREATERICHTEXTITEM ("Attachment")
End If


' send e-mail !!!!
MailDoc.PostedDate = Now()
' if error in attachment or name of recipients
'On Error GoTo errorhandler1

MailDoc.Send 0, recipient

'Set Maildb = Nothing
'Set MailDoc = Nothing
'Set attachME = Nothing
'Set Session = Nothing
'Set EmbedObj1 = Nothing

'Unload Me
'Exit Sub
' setting up the error message

Set Maildb = Nothing
Set MailDoc = Nothing
Set attachME = Nothing
Set Session = Nothing
Set EmbedObj1 = Nothing
' unloading the userform
'Unload Me
Msg = "E-mail has been sent to " & recipient & Chr(13) & Chr(10) & Chr(13) & Chr(10) & "Press OK to continue."
Style = vbOKOnly + vbInformation
Title = "Open Issues List"
Response = MsgBox(Msg, Style, Title, Help, Ctxt)


But the problem is that when the Variable Addr contains more than one email addresses separated by a comma Lotus is unable to send emails and bounces the mail back saying "Error transferring to 172.16.0.2; Invalid Internet address specified" .... I've tried separating the email addresses with the greater than and less than sign at the beginning and end of emails ("<email>") but that way Lotus does not give me any errors but neither does the email reach the recipient ... I'm trying to find a solution to this issue ... if any one has any idea please let me know via email or through this forum.
Sep 19 '07 #1
0 1752

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Stuart Mueller | last post by:
I have an exchange server, that I sometimes use to perform mail shots to clients on our database, these can be upwards of 1000 at a time. As we don't want different clients to see who we are...
1
by: Ian Taylor | last post by:
Hi all... Is it possible to send RTF-formatted emails using the .NET SmtpMail implementation? I can only find provision in the BodyFormat property of the message to send plain text or HTML...
3
by: VB Programmer | last post by:
My company has it's own webserver, which is going to host our ASP.NET web application. We want the website to be able to send out emails. 1. What do I need on the server so that it has the...
2
by: Mr. x | last post by:
Hello, I am sending emails with Hebrew contents. When receiving emails - I cannot see the Hebrew characters (it is not outlook express configuration, because when receiving emails from friends -...
3
by: A | last post by:
Hi all! I would like to ask a question on sending emails... I have a web application that requires sending emails using email templates. The templates that I've made are separate HTML files...
3
by: Ant | last post by:
Hi, I'm using the MailMessage & smtpMail classes in System.Web.Mail to send mail, however it's not sending any emails. I'm using it on a Windows 2003 server. The simplest way to use this is...
8
by: windandwaves | last post by:
Hi Folk I want to send out a basic newsletter from my MySql database of contacts. Does anyone know a nice and simple bit of PHP that allows me to do this? TIA - Nicolas
5
by: Jai | last post by:
Hi, I am in a problem of sending mass emails(newsletter) to my website members. Actually my problem is this: I want to send newsletter to my website members. But I had given a facility for...
1
by: robbiesmith79 | last post by:
Just so this is out there on the web, I battled the past 24 hours about this. Background info... I developed a ecommerce website in PHP 4 on a shared linux hosting plan from GoDaddy and had the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.