查询初始电子邮件? [英] Query to Initial Email?

查看:92
本文介绍了查询初始电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们,

我还有最后一个问题需要解决,然后我的数据库基本上已经完成了b $ b ...我非常感谢任何帮助

可以为我提供。

目前我已经设置了一个查询,只显示满足

某些标准的记录......因此,排除所有不符合此标准的记录(仅用于记录标准是我的数据库中的任何记录

,在其两个月内)截止日期

字段。我需要找到一种循环遍历所有这些记录的方法

查询中显示然后自动发送电子邮件给我自己

通知我此特定记录已基本过期...到达

其截止日期。


现在我已经编写了启动电子邮件的代码。

命令的一个方面...这个工作正常....但是,我确实需要一些帮助

自动化过程....并且想知道是否有人可以提供

我使用的代码,例如,在表格中On Load

事件,这将启动电子邮件"代码我已经写了

标题为SendMail?????所以基本上,如果有人可以请你节省

的时间,想获得一些循环遍历查询发现的所有

记录的代码,以自动化我的SendMail。命令....它将非常感谢



也有人知道如何将记录中的字段传递到

电子邮件......即Outlook?

亲切的问候,


Liam

解决方案


Li **** @ awamarine.com.au 写道:

嘿伙计们,
我有最后一个问题需要解决,然后我的数据库基本上已经完成了...因此我非常感谢任何帮助
能够为我提供。
目前我已经设置了一个查询,只显示符合某些标准的记录...因此排除所有不是
符合此标准(仅用于记录标准是我的数据库中的任何记录,其在截止日期字段的两个月内)。我需要找到一种方法来循环查看查询中显示的所有这些记录,然后自动发送电子邮件给我自己
通知我这个特定记录已经过期了......已达到
它的截止日期。

现在我已经编写了启动电子邮件的代码。
命令的方面......这工作正常....但是,我确实需要一些帮助来自动化过程....并且想知道是否有人可以提供
我使用的代码,例如,在表格On Load事件中,将启动电子邮件事件。代码我已经写了
标题为SendMail?????所以基本上,如果有人可以请你节省时间,想获得一些循环遍历查询发现的所有
记录的代码,以自动化我的SendMail。命令....它将非常感谢!

也有人知道如何将记录中的字段传递到电子邮件的正文......即Outlook ?

亲切的问候,

Liam




利亚姆,


好的,发送一封_single_电子邮件,其中包含查询中的值列表

消息正文....


你可以创建一个创建消息体的函数(我会调用

函数fMsgBody),然后只需更改消息体赋值。


first,the fMsgBody函数。


函数fMsgBody()As String

dim rsDue as dao.recordset

dim strList as string'' - - 转储

查询中的所有名称


set rsDue = DBEngine(0)(0).OpenRecordset(" qryDueMails")

直到rsDue.EOF

strList = rsDue.Fields(" FirstName")& " " &

rsDue.Fields(" LastName")& vbCrLf

rsDue.MoveNext

loop


fMsgBody ="以下帐户到期日期:" &安培; vbcrlf& strList


rsDue.Close

set rsDue = Nothing


结束功能


那么你只需在你的电子邮件代码中包含这个。


而不是说明的行

strMsg = Nz(我!txtBody,"


你可以使用:

strMsg = fMsgBody


(函数为你构建消息体。)


然后剩下的代码将是相同的。


清除泥土,对吗?


非常感谢你的回复....他们总是非常有帮助!

清除泥...我正确...哈哈哈......道歉但是我相对而言... b $ b新的全部......而且遗憾的是缺少必要的

经验......信息你我刚刚提供了我的意义

然而在我的项目中实现这个是另一个故事....

代码:

函数fMsgBody()作为字符串
dim rsDue as dao.recordset
dim strList as string''---将所有名称转储到
查询中

设置rsDue = DBEngine (0)(0).OpenRecordset(" qryEmail")
直到rsDue.EOF
strList = rsDue.Fields(" IMO Number")& " " &安培; rsDue.Fields(Vessel Name)& " " &安培; (发行日期)& " " &安培; (截止日期)& vbCrLf
rsDue.MoveNext
循环

fMsgBody ="以下帐户到期: &安培; vbcrlf& strList

rsDue.Close
设置rsDue =没什么

结束功能




我在哪里放置这个代码...这是怎么回事?
发起我的SendMail功能?这只是将变量传递给

SendMail吗?功能我有....或者是用它来实现

其他代码来循环这些记录...换句话说,我的意思是

使用其他循环遍历记录的代码和这段代码只是

后半部分将变量(字段)传递给SendMail

函数我有吗? br $>

亲切的问候,


利亚姆



Li****@awamarine.com.au 写道:

非常感谢你的回复....他们总是非常有帮助!




利亚姆,


您可能想查看此链接
http://groups.google .com / group / comp .... dbc3a94dadba80


Lyle提供了一个使用CDOSys发送电子邮件的简单示例。


哟你可以将消息的.Body属性设置为

函数的结果,就像这样


Public Sub VerySimpleSendMailWithCDOSample()

''需要引用cdosys.dll

''(Microsoft CDO for Windows 2000库)


Dim iCfg作为CDO.Configuration

Dim iMsg作为CDO.Message


设置iCfg =新CDO.Configuration

设置iMsg =新CDO.Message


使用iCfg.Fields

..Item(cdoSendUsingMethod)= cdoSendUsingPort

..Item(cdoSMTPServerPort)= 25

..Item(cdoSMTPServer)=" smtp.mail.yahoo.ca"

..Item(cdoSMTPAuthenticate)= cdoBasic

..Item(cdoSendUserName)=" ; lylefair"

..Item(cdoSendPassword)="密码"

..Item(cdoSendEmailAddress)=" Lyle Fairfield< lylef ... @ yahoo。 ca>"

..更新

结束


使用iMsg

..Configurati on = iCfg

..Subject =" Test"

..To =" lylefairfi ... @ aim.com"


''---。TextBody ="测试"

..TextBody = fMsgBody()''< ===将fMsgBody的结果填入

..Textbody财产电子邮件。

..发送

结束

结束子


hey guys,
I have one last problem to fix, and then my database is essentially
done...I would therefore very much appreciate any assistance anyone
would be able to provide me with.
Currently I have set up a Query to show only records that meet a
certain criteria...therefore excluding all of the records that do not
meet this criteria (just for the record the criteria is any record
within my database that falls within two months of its "Due Date"
field). I need to find a way to cycle through all of these records
shown in the query and then automatically send an email to myself
notifying me that this particular record has almost expired...reached
its "Due Date".

Now I have already written the code to launch the "email" aspect of the
command...and this is working fine....I do, however, require some help
in automating the process....and was wondering if anyone could provide
me with the code to use, for example, within the form(s) "On Load"
event, that would initiate the "email" code I have already written
titled "SendMail"????? So essentially, if anyone could please spare the
time, would like to obtain some code that loops through all of the
records that query discovers to automate my "SendMail" command....it
would be very much appreciated!

Also does anyone know how to pass fields from a record into the body of
the email...i.e Outlook?
Kind Regards,

Liam

解决方案


Li****@awamarine.com.au wrote:

hey guys,
I have one last problem to fix, and then my database is essentially
done...I would therefore very much appreciate any assistance anyone
would be able to provide me with.
Currently I have set up a Query to show only records that meet a
certain criteria...therefore excluding all of the records that do not
meet this criteria (just for the record the criteria is any record
within my database that falls within two months of its "Due Date"
field). I need to find a way to cycle through all of these records
shown in the query and then automatically send an email to myself
notifying me that this particular record has almost expired...reached
its "Due Date".

Now I have already written the code to launch the "email" aspect of the
command...and this is working fine....I do, however, require some help
in automating the process....and was wondering if anyone could provide
me with the code to use, for example, within the form(s) "On Load"
event, that would initiate the "email" code I have already written
titled "SendMail"????? So essentially, if anyone could please spare the
time, would like to obtain some code that loops through all of the
records that query discovers to automate my "SendMail" command....it
would be very much appreciated!

Also does anyone know how to pass fields from a record into the body of
the email...i.e Outlook?
Kind Regards,

Liam



Liam,

OK, send a _single_ e-mail with the list of values from the query in
the body of the message....

you could create a function to create the message body (I''ll call the
function fMsgBody), and then just change the message body assignment.

first, the fMsgBody function.

Function fMsgBody() As String
dim rsDue as dao.recordset
dim strList as string ''---place to dump all the names in the
query

set rsDue=DBEngine(0)(0).OpenRecordset("qryDueMails")
do until rsDue.EOF
strList=rsDue.Fields("FirstName") & " " &
rsDue.Fields("LastName") & vbCrLf
rsDue.MoveNext
loop

fMsgBody="The following accounts are due:" & vbcrlf & strList

rsDue.Close
set rsDue=Nothing

End Function

then you''d just include this in your e-mail code.

Instead of the line that says
strMsg = Nz(Me!txtBody,"")

you could use:
strMsg = fMsgBody

(the function that builds the message body for you).

Then the rest of the code would be the same.

Clear as mud, right?


Thankyou so much for your reply....they are always extremely helpful!
Clear as mud...to me correct...hahaha...apologies BUT iam relatively
new too all of this...and unfortunately do lack the neccessary
experience...the informaiton you have just provided me makes sense
however implementing this into my project is another story....
The code:

Function fMsgBody() As String
dim rsDue as dao.recordset
dim strList as string ''---place to dump all the names in the
query

set rsDue=DBEngine(0)(0).OpenRecordset("qryEmail")
do until rsDue.EOF
strList=rsDue.Fields("IMO Number") & " " & rsDue.Fields("Vessel Name") & " " & ("Date of Issue") & " " & ("Due Date") & vbCrLf
rsDue.MoveNext
loop

fMsgBody="The following accounts are due:" & vbcrlf & strList

rsDue.Close
set rsDue=Nothing

End Function



Where about am I surposed to place this code...and how does this
initiate my "SendMail" function? Does this just pass the variables to
the "SendMail" function I have....or is it meant to be implemented with
other code to loop through these records...in other words am I meant to
use other code to loop through the records and this code just being the
latter half of it to pass the variables (fields) to the "SendMail"
function I have?

Kind Regards,

Liam



Li****@awamarine.com.au wrote:

Thankyou so much for your reply....they are always extremely helpful!



Liam,

you might want to check out this link
http://groups.google.com/group/comp....dbc3a94dadba80

Lyle gives a good simple example of using CDOSys to send e-mails.

You could just set the .Body property of the message to the result of
the function, like this

Public Sub VerySimpleSendMailWithCDOSample()
'' requires reference to cdosys.dll
'' (Microsoft CDO for Windows 2000 library)

Dim iCfg As CDO.Configuration
Dim iMsg As CDO.Message

Set iCfg = New CDO.Configuration
Set iMsg = New CDO.Message

With iCfg.Fields
..Item(cdoSendUsingMethod) = cdoSendUsingPort
..Item(cdoSMTPServerPort) = 25
..Item(cdoSMTPServer) = "smtp.mail.yahoo.ca"
..Item(cdoSMTPAuthenticate) = cdoBasic
..Item(cdoSendUserName) = "lylefair"
..Item(cdoSendPassword) = "Password"
..Item(cdoSendEmailAddress) = "Lyle Fairfield <lylef...@yahoo.ca>"
..Update
End With

With iMsg
..Configuration = iCfg
..Subject = "Test"
..To = "lylefairfi...@aim.com"

''---.TextBody = "Test"
..TextBody = fMsgBody() ''<=== stuff the result of fMsgBody into the
..Textbody property of the email.
..Send
End With
End Sub


这篇关于查询初始电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆