Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 18th, 2006, 06:36 AM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,186 nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 7 h 36 m 24 sec
Reputation Power: 699
Change outlook account with MAPI

hi everyone,

I have created this vb script file to send out a newsletter,
but I have 3 email accounts in my outlook, so it goes into
the Draft folder with the default account, but I would like
to use the account for sending the newsletter.

here is the script so far:
Code:
Function ValidateEmail(inEmail)
	Dim email
	email = inEmail
	
	Dim re
	Set re = New RegExp
	re.Pattern = "^[\w\-\.]*[\w\.]\@[\w\.]*[\w\-\.]+[\w\-]+[\w]\.+[\w]+[\w $]"
	
	If re.Test(email) = False Then
		ValidateEmail = False
	Else
		ValidateEmail = True
	End If
End Function




Dim ToAddress
Dim MessageSubject
Dim MessageBody
Dim ol, ns, newMail
Dim conn, rs, count
count = 0

ToAddress = ""
MessageSubject = "SA BookNews Online Weekly Newsletter - Friday 18 August 2006"

'----READ BODY FROM TEXT FILE
Set fs=CreateObject("Scripting.FileSystemObject")
Set f=fs.OpenTextFile("c:\newsletter.txt", 1)

MessageBody = f.ReadAll

f.Close

Set f=Nothing
Set fs=Nothing
'----END OF READ BODY FROM TEXT FILE


'----READ EMAILS FROM DB
set conn = CreateObject("ADODB.Connection")
set rs = CreateObject("ADODB.Recordset")

conn.Open "*******"
rs.Open "select DISTINCT ltrim(rtrim(nls_email)) as EMail from bkn_NewsLetterSubscriberMail " & _
			"where nls_RequestedThisLetter IS NULL or nls_RequestedThisLetter = 1", conn

while not rs.EOF

if ValidateEmail(rs("Email")) then
	ToAddress = ToAddress & rs("EMail") & ";"
	count = count + 1
end if
	
	rs.MoveNext

if count = 25 or rs.EOF then

	'----SEND EMAIL
	Set ol = WScript.CreateObject("Outlook.Application")
	Set ns = ol.getNamespace("MAPI")
	
	Set newMail = ol.CreateItem(olMailItem)
	newMail.Subject = MessageSubject
	newMail.HTMLBody = MessageBody
		
	   newMail.BCC = ToAddress
	   newMail.Save	

	Set ol = Nothing
	'----END OF SEND EMAIL
	
	count = 0
	ToAddress = ""
end if

wend 

conn.close
rs.close
set conn = nothing
set rs = nothing

msgbox "Email Export Complete!"

there must be a way to select which account to send the mail with?

thanx in advance
__________________
Look! Its a ShemZilla



Last edited by nofriends : December 8th, 2006 at 04:22 AM.

Reply With Quote
  #2  
Old December 8th, 2006, 04:22 AM
nofriends's Avatar
nofriends nofriends is offline
Senior Water Wizard
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Aug 2004
Location: Cape Town, RSA
Posts: 10,186 nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)nofriends User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1Folding Points: 112786 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 2 Days 7 h 36 m 24 sec
Reputation Power: 699
I wonder if anyone has a solution for this....

Reply With Quote
  #3  
Old December 8th, 2006, 02:22 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 57 m 26 sec
Reputation Power: 181
I don't know of any way to programatically change the sender in Outlook. I'd just write a VB program or VB script that used an email component to send the mail rather than outlook.
Comments on this post
nofriends agrees: thanx for the info
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Change outlook account with MAPI


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT